Programming3 Test Exam
Programming3 Test Exam
All questions in this exam are related to a Football competition/championship, with players, teams and
football matches (games).
Create (in class Program) a method void Assignment1() and call this method from the Start
method. This Assignment1-method will be used for creating/displaying a few objects.
b) Write a constructor for class FootballPlayer which allows you to fill each field of class
FootballPlayer with a value.
Each player has a transfer value, the amount to be paid when a player moves from one football
club to another. This transfer value depends on the age of the player. Therefor, class
FootballPlayer gets a method int CalculateTransferValue(). The value (in millions) is
computed with the formula: (27 – age) * 2.
d) Write the method int CalculateTransferValue().
e) Write the method string ToString() for class FootballPlayer, that returns the content of a
FootballPlayer-object as a string. Of course you make use of method
CalculateTransferValue() from assignment 1d. An example of the output of the ToString-
method is shown below.
f) Write the shortest possible statement (in method Assignment1) for showing the content of
a created FootballPlayer-object (on screen) with the ToString-method.
ICT, Information Technology
Course: Programming 3 (1918IN133A) Page: 2 van 6
Term: 1.4 Examiner: G. Van Dijken
Date: Wednesday, June 17th, 2020 Duration: 120 minutes
b) In the Assignment2-method write a statement for creating an international player with name
“Donny van der Beek”, age 23, and 9 international games played.
For an InternationalPlayer-object the extra transfer value is computed as follows: for each
international game played, the transfer value is increased by half a million.
c) Implement method CalculateTransferValue() for class InternationalPlayer. Make
clever use of the already existing code in base class FootballPlayer.
d) Method ToString() for class InternationalPlayer is also a bit different then for class
FootballPlayer. Write the method ToString() and make clever use of already existing code in
base class FootballPlayer. An example of the output is shown below.
e) In method Assignment2 create a list that can contain FootballPlayer-objects and also
InternationalPlayer-objects. Add a few objects of both types to the list, and next, display
the content of this list to the screen. An example is shown below.
ICT, Information Technology
Course: Programming 3 (1918IN133A) Page: 3 van 6
Term: 1.4 Examiner: G. Van Dijken
Date: Wednesday, June 17th, 2020 Duration: 120 minutes
a) Create (in a separate file) a class FootballTeam and add to this class a read-only property for
a list of players (of type FootballPlayer).
b) Add to class FootballTeam a read-only property ‘Name’ for storing the name of the team, and
use a backing field (backing store) for this property.
c) Add to class FootballTeam an automatic property ‘TotalPoints’ (int) for the points of a team.
e) Give class FootballTeam a constructor that stores the name (constructor parameter), creates
the list of players, and initializes the total points to 0.
a) Create a class FootballMatch, it should not be possible to create objects from this class. Give
this class a member for the ‘home’ team (HomeTeam) and a member for the ‘away’ team
(AwayTeam), both of type FootballTeam. Add a constructor to pass both teams (parameters).
c) Create a class GroupStageMatch that can be used as a ChampionshipMatch, and give this
class a string-member for storing the group name. Add to this class a constructor so (also)
the group name can be passed.
d) Create a class KnockoutMatch that can be used as a ChampionshipMatch, and give this class
a member ‘KnockoutType’ (enumeration with options: QuarterFinal, SemiFinal, Final). Add to
this class a constructor so (also) the knockout type can be passed.
ICT, Information Technology
Course: Programming 3 (1918IN133A) Page: 5 van 6
Term: 1.4 Examiner: G. Van Dijken
Date: Wednesday, June 17th, 2020 Duration: 120 minutes
d) Create a separate method to avoid duplicate code for assignments 5b and 5c.
a) Create a class Competition with a list of teams (FootballTeam) and a list of matches
(FootballMatch). Add a constructor for creating these 2 lists.
c) Add to class Competition an (obvious) data structure, so for each football match a result can
be linked. Add a method CalculateTeamPoints that assigns points to all teams according to the
played football matches.
Additionally, you can add a few match results to the competition, and then calculate the points
for the teams (using CalculateTeamPoints); this is just a check for yourself (so, no points will
be given for it).