August
1999 QUESTION 3 Total Marks: 20 Marks |
Click here to access other
questions
Click to access |
The Singapore
Football League requires a program to maintain information about the football league. Each
team in the league has a name (a character string), a current league position (an integer)
and the number of games they have played (an integer).
|
||
(a) | Give a declaration of the class Team which
contains
|
[5] |
(b) | A league is a
collection of 20 teams. Give a definition of a class League, which contains an array of 20
teams.
|
[2] |
(c) | Since each team in
the league plays each other team, the total number of games played for all teams is an
even number. Write a function, called check_fixture, which sums all of the games played by
all teams in the league, and returns 0 if it is an even number, or -1 otherwise.
|
[6] |
(d) | Write a function
display_league, which takes an object of type League,prints the names of the teams in that
league in descending order of position, from position 1 to 20. You should use a simple
sequential search to locate the teams.
|
[7] |