This is a
simple programming-contest sort of exercise.
You "need"
only two classes.
+ a Team
- knows
its name (a String of at most 30 characters)
* This
should be passed when the Team is created;
the
rest of the program should NOT call (Team new)
and
should NEVER see an un#initialize-d Team instance.
- knows the number of
matches it has won, drawn, and lost
(non-negative Integers,
initially zero).
- can report what it knows
- can report the total match
count and point score
- can be told that it has
won, drawn, or lost another match.
+ a Tournament
- has a collection of Teams
that it knows by name
(a Dictionary)
- and an sequence,
initially undefined.
- can read a set of match
triples from a stream,
forwarding the
information about wins, draws, and losses
to Team instances, which
are created when a new name is found,
- can convert the values
of the teams collection to a
sorted collection that
is sorted by a somewhat vague order,
I chose
- descending on point
score, then
- descending on wins,
then
- ascending on
losses, then
- ascending on name.
- can write the sorted
teams to a stream in tabular form.
! Has a class method that
does
(self new) read:
<<source>>; sort; write:
<<destination>>
Frankly, formatting the
output was the hardest part.