Competency Exam 15-111/200
Assignment
Professional golf tournaments are generally played over four days. After the first two days, a score is determined that is called "the cut". "The cut" is a score that is used to decide which players go into the final two rounds: players with total scores less than or equal to the cut advance to the final round. Players whose score is greater than the cut are eliminated.
Example:
Cut: 145
Tiger Woods 70 69
Greg Norman 71 76
In this case Tiger Woods advances to the final two rounds (70 + 69 is less than 145), but Greg Norman wouldn’t (71 + 76 is greater than 145).
You will be implementing one method for a golf tournament:
1) A method of the LinkedList class, sort(), that will sort the list from
lowest to highest, 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 data base. All is implemented except the sort() method which you must implement. This method sorts items in the list, form lowest to highest, according to compareTo().
PlayersDB.java is a class that implements a database (LinkedList) of objects of another class called Player. It is implement 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 sort() to put the players in order, and the print the list again – this time in order.
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.
Sample output for both input files:
<golf1.txt>
Enter the name of the file:
golf1.txt
File golf1.txt has been
opened.
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
Players in the tournament by
score (lowest to highest):
Ernie, Els 70 67 137
Tiger, Woods 70 69 139
Nick, Faldo 75 67 142
Stewart, Cink 74 70 144
Fred, Couples 73 73 146
Tom, Watson 71 76 147
<golf2.txt>
Enter the name of the file:
golf2.txt
File golf2.txt has been
opened.
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
Players in the tournament by
score (lowest to highest):
Angel, Cabrera 68 71 139
Phil, Mickelson 69 72 141
Craig, Stadler 73 72 145
Nick, Price 70 76 146
Greg, Norman 71 76 147