0% found this document useful (0 votes)
10 views6 pages

Programming3 Test Exam

The document describes assignments for a programming exam on creating classes to model football/soccer data. It involves creating classes for players, teams, and different types of matches. Classes are created for football players, international players, teams, and different match types like group stage matches and knockout matches. Properties and inheritance are used between the classes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

Programming3 Test Exam

The document describes assignments for a programming exam on creating classes to model football/soccer data. It involves creating classes for players, teams, and different types of matches. Classes are created for football players, international players, teams, and different match types like group stage matches and knockout matches. Properties and inheritance are used between the classes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

ICT, Information Technology

Course: Programming 3 (1918IN133A) Page: 1 van 6


Term: 1.4 Examiner: G. Van Dijken
Date: Wednesday, June 17th, 2020 Duration: 120 minutes

All questions in this exam are related to a Football competition/championship, with players, teams and
football matches (games).

Assignment 1: FootballPlayer (15 points)


In this first assignment we will create a class for a football player.

Let’s get started:


Create a Console project with name ‘Programming3-assignments’, and give the solution the
name ‘Programming3-Exam’. There will be only one VisualStudio-project for this exam.

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.

a) Create in a separate file (FootballPlayer.cs) a class FootballPlayer containing 2 fields:


(string) name and (int) age. Make sure these 2 fields are not accessible from outside, but
only within the class itself and derived classes.

b) Write a constructor for class FootballPlayer which allows you to fill each field of class
FootballPlayer with a value.

c) Write in method Assignment1 a statement for creating a FootballPlayer-object with name


‘Peter de Groot’ and age 25.

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

Assignment 2: Inheritance (15 points)


For international football players more information is being recorded, and the transfer value is
computed differently. Therefor, we will create a class InternationalPlayer derived from class
FootballPlayer. This class InternationalPlayer has an extra int-field: gamesPlayed (the
number of international matches played).

Let’s get started:


Create (in class Program) a method void Assignment2() and call this method from the Start
method. This Assignment2-method will be used for creating/displaying a few objects.

a) Create in a separate file (InternationalPlayer.cs) a class InternationalPlayer. Give this


class a constructor which allows you to fill each field of InternationalPlayer with a value.
Make clever use of the fact that InternationalPlayer derives from class FootballPlayer.

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

Assignment 3: Properties (15 points)


In this assignment we will implement a class FootballTeam that can contain players.

Let’s get started:


Create (in class Program) a method void Assignment3() and call this method from the Start
method. This Assignment3-method will be used for creating/displaying a few objects.

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.

d) Add to class FootballTeam a calculated (computed) property ‘TotalTransferValue’ that returns


the sum of transfer values of all players. Make use of the method
CalculateTransferValue() of class FootballPlayer.

e) Give class FootballTeam a constructor that stores the name (constructor parameter), creates
the list of players, and initializes the total points to 0.

f) In method Assignment3 create a FootballTeam-object, and add a few FootballPlayer- and


InternationalPlayer-objects to it. Next, display the total transfer value of the team.
ICT, Information Technology
Course: Programming 3 (1918IN133A) Page: 4 van 6
Term: 1.4 Examiner: G. Van Dijken
Date: Wednesday, June 17th, 2020 Duration: 120 minutes

Assignment 4: Football matches (15 points)


In this assignment, we will implement different kinds of football matches. A match can be part of a
competition, or part of a championship. There are 2 different championship matches: a groupstage
match, and a knockout match.

Let’s get started:

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).

b) Create a class CompetitionMatch with int-member roundNumber and a class


ChampionshipMatch (without members); both classes are football matches (FootballMatch).
Objects can only be created from class CompetitionMatch, not from class
ChampionshipMatch. Add to class CompetitionMatch a constructor so (also) the round
number can be passed.

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

Assignment 5: Football match results (15 points)


In this assignment we will implement a class for recording the result of a Football match.

Let’s get started:


Create (in class Program) a method void Assignment5() and call this method from the Start
method. This Assignment5-method will be used for creating/displaying a few objects.

a) Create a class FootballMatchResult with two read-only (int) properties: HomeTeamGoals


and AwayTeamGoals. Give this class a constructor that stores these 2 values (parameters).

b) Add to class FootballMatchResult a calculated property HomeTeamPoints that returns the


points for the home-team, according to the goals.
Points for the teams are calculated as follows:
when both teams have the same number of goals: 1 point for both teams, else 3 points for the
team with the most goals, and 0 for the other team.

c) Add to class FootballMatchResult a calculated property AwayTeamPoints that returns the


points for the away-team, according to the goals.

d) Create a separate method to avoid duplicate code for assignments 5b and 5c.

e) In method Assigmment5 create a few FootballMatchResult-objects, and display the points


for the home-team and the away-team. An example is shown below.
ICT, Information Technology
Course: Programming 3 (1918IN133A) Page: 6 van 6
Term: 1.4 Examiner: G. Van Dijken
Date: Wednesday, June 17th, 2020 Duration: 120 minutes

Assignment 6: Football competition (15 points)


So far, we only worked with ‘unconnected’ football matches and results. In this assignment, we will
add a ‘coordinating’ class: a football competition.

Let’s get started:


Create (in class Program) a method void Assignment6() and call this method from the Start
method. This Assignment6-method will be used for creating/displaying a few objects.

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.

b) Implement a method GenerateMatches that generates football matches. Create a football


match (CompetitionMatch) for each combination of home team and away team. Tip: iterate
through all teams in a nested loop, and create for each combination a match (of course a team
will not be playing against itself).

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.

d) In method Assignment6 create a Competition-object, and add a few teams to this


competition. Next, generate the competition matches using method GenerateMatches.

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).

You might also like