I am just goint to start doing it.
This is the detail
Country.java is a class to represent a country in medal tally. It has an attribute of
country name, and attributes to record the numbers of gold, silver, bronze, and total
medals. In this class,
you should also define constructors, and assessor, mutator
methods.
Task 2
MedalTally.java is a class to model a medal tally, containing all the countries winning
any medal in an Olympic Games. It uses an array, Country[], to store medal records of
countries. Define constructors and relevant methods to manage the medal tally.
Task 3
The driver program, LondonGames.java starts by calling the load( ) method. This
method prompts (asks) the user for the name of an input text file. The load( ) method
must check that the requested file exists and is not empty. This is to be done using the
Java File class, not try/catch blocks.
If the text file exists and is not empty, then the contents of the text file are read into the
Country[] array.
The format of each record of this file is country name, numbers of gold, silver, bronze and
total medals separated by white space. For example, the first line of the provided input file,
London2012.txt, which stores the top 20 countries on the medal tally at August 11,
2012:
United States of America 41 26 27 94
means USA had 41 gold medals, 26 silver, 27 bronze, and total 94 medals.
After the file has been read into the array, the file is closed. All further uses of this program
are with the array, not the file, except, of course, for saving the array back to a file. After
the file has been read, the user is presented with the main menu, as follows:
Welcome to the London Olympic Games Medal Tally
Main Menu
1. Add Country
2. Delete Country
3. Add Medal(s)
4. Display Medal Tally
5. Save to file
6. Exit
Enter choice >>
Implement the functionality of each method as follows (assume user input is correct):
1. Add Country
Add Menu
1. Country Name
2. Exit
Enter choice >>
The Add menu presents the user with a sub-menu as shown above
Picking choice 1 will attempt to add a new Country to the medal tally. This means
that a new Country object will created and inserted to the Country[] array that
represents the medal tally. The user will be asked to input the name of a new
country. At this stage the new country has no medals; you can add medal(s) from the
main menu after the country is added.
Selecting choice 2 returns the program to the main menu
2. Delete Country
Selecting this main menu choice prompts (asks) the user for the country name at
which to attempt to remove from the medal tally. Only one Country can be removed
per call to this menu choice. After deletion, the program returns to the main menu.
3. Add Medal(s)
This menu choice prompts (asks) the country name, and numbers of gold, silver and
bronze medals to add to that country, which is already on the tally.
4. Display Medal Tally
This choice displays all the countries and numbers of medals. After display, the
programs returns to the main menu.
5. Save to file
When this option is selected, the user is asked for the name of a text file. If the file
can be opened, then the contents of the entire array is written into the file.
The format of the output must be the same as the format of the input file. The output
file must be able to be used as input file the next time the program is run.
The program does NOT exit when this menu choice is chosen. After writing to the
output file, the program returns to the main menu
6. Exit
Selecting this option exits the program. The user is NOT asked if they want to save
changes.