200mastery3/Instructions.html 0100755 0143546 0000144 00000005577 07561661352 0015430 0 ustar 00djj 0000000 0011064
Practice mastery exam 3
Competency Exam 15-111/200
Assignment
A golf tournament consists of several matches which are scored
individually. Each player computes their final score by
summing the scores from each round. The lowest overall score
wins. Consider the following data from a hypothetical two
round tournament among three players.
Example:
Tiger Woods 70 69
Greg Norman 71 76
Phil Mickelson 69 72
In this case Tiger Woods has a total score of 139 (70 + 69),
Greg Norman has a total score of 147 (71 + 76), and Phil
Mickelson has a total score of 141 (69 + 72). Since his
score is lowest, Tiger wins this tournament. We should
remove Greg and Phil from the roster leaving only the winner.
You will be implementing one method for a golf tournament:
keepSmallest()
This is a method of the LinkedList class that will remove
all the elements from the list except the smallest one
according to compareTo().
Project files
-
Player.java has been fully implemented, and it contains scoring
details for a golf player. Each player has a first name, a last
name, a series of integers representing his scores in two rounds
of golf, and a total (cumulative) score. The total score is simply
the addition of all the scores. For example, if one player scores
73 and 72, then his total score is 145.
-
LinkedList.java is a class that implements a linked list, which is
the basis of the PlayersDB database. All is implemented except the
keepSmallest() method which you must implement. This method
removes all items except the smallest, according to compareTo().
-
PlayersDB.java is a class that implements a database (LinkedList) of
objects of another class called Player. It is implemented for you. It
will print out the scores of each player, as they were read from the
file. It will then call your new LinkedList keepSmallest() to
keep only the winner, and then print the list again.
Sample output
There are two input files that could be used with your class: golf1.txt
and golf2.txt. Make sure you test your solution with both input files.
Here is the sample output for both input files:
golf1.txt
Enter the name of the file: golf1.txt
The players in the tournament:
Ernie, Els 70 67 137
Tom, Watson 71 76 147
Fred, Couples 73 73 146
Nick, Faldo 75 67 142
Tiger, Woods 70 69 139
Stewart, Cink 74 70 144
Winner of the tournament:
Ernie, Els 70 67 137
golf2.txt
Enter the name of the file: golf2.txt
Players in the tournament:
Nick, Price 70 76 146
Craig, Stadler 73 72 145
Angel, Cabrera 68 71 139
Phil, Mickelson 69 72 141
Greg, Norman 71 76 147
Winner of the tournament:
Angel, Cabrera 68 71 139