In this lab you will write a program to keep track of Olympic Athletes. Each athlete represents their home country, and may compete in several events in the Olympics. In each event the athlete has a chance to win a gold medal (if the athlete comes in first), a silver medal (if the athlete comes in second), or a bronze medal (if the athlete comes in third).
The program will use an Athlete object to hold the information about an athlete. The Athlete class will contain the following information for each athlete: the athlete’s name, country, event, and their final rank in the event (finished 1st, 2nd, 3rd, 4th, etc...). Athletes who compete in more than one event will have more than one Athlete object. Athlete will need methods to create and print these objects. Athlete will also need to implement the Comparable Interface and have a compareTo method that will be able to compare Athlete objects appropriately.
The class OlympicAthletes will hold the information about all athletes that competed in a given Olympic. An OlympicAthletes object will contain an ordered list of Athlete objects. The Athletes will be ordered by country, and by name within country.
The class OlympicAthletes will need member functions for the following:
Your main program will create an OlympicAthletes object for the Summer 2012 games that were held in London or the Winter 2014 games that were held in Sochi. The data for the Athletes will be read from a file. Your file must use the format below with the data for each athlete entered in this order: name, country, event, and rank. Each of these on a separate line. You can assume that the data in the input file is valid, and your program should read until end of file (do not use a sentinel). For example a very small data file would look like:
Matthew Grevers
USA
100M BACKSTROKE MEN
1
Nick Thoman
USA
100M BACKSTROKE MEN
2
Ryosuke Irie
Japan
100M BACKSTROKE MEN
3
Xiaoxia LI
China
TABLE TENNIS, SINGLES WOMEN
1
Ning DING
China
TABLE TENNIS, SINGLES WOMEN
2
You file should have at least 20 athletes. You can obtain Olympic information by going to www.Olympics.com or go to your favorite search engine and perform a search on the Summer 2012 games or the Winter 2014 games.
Your driver (console) program should read the input file and store the data in your OlympicAthletes object. Then main should give the user a menu so they can print all athletes, look up athletes, look up events, look up medal winners (in the 3 ways described above), add athletes and delete athletes. Let the user continue until they want to quit. If the user gives an invalid response to the menu, give an error message and continue.
Once you get this application working then use Java serialization to save the ordered list of Athlete objects for later use, possibly as input to another run of your application.
You can use the Golf application on pages 418 – 421 in your text and the Song List application on pages 451 – 458 in your text as references when designing and writing your application. You will be developing three classes in addition to using one of the ordered list classes presented in the text. The three classes are Athlete, OlympicAthletes, and your driver (console) class.