Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

CIS 162 Project 3 Olympic Medalists Database Due Date See due date for your section on Blackboard. Suggested guidelines for time required for each phase:  Phase 1 – one day  Phase 2 – two weeks ...

1 answer below »

CIS 162 Project 3
Olympic Medalists Database
Due Date
See due date for your section on Blackboard.
Suggested guidelines for time required for each phase:
 Phase 1 – one day
 Phase 2 – two weeks
 Phase 3 – one day
Before Starting the Project
 You are responsible for understanding and adhering to the School of CIS Guidelines for
Academic Honesty.
 Read chapters 10 and 11 – GUI and A
ayLists
 Read this entire project description before starting
Learning Objectives
After completing this project, you should be able to:
 use A
ayLists to maintain and process collections of objects
 use for-each loops/enhanced for loops
 read data from external text files
Olympic Medalists
We are providing a dataset (.csv file) with the records for the Summer Olympics Medals (1976-
XXXXXXXXXXThis dataset is a list of all the medal winners in the Summer Olympics from 1976
Montreal to 2008 Beijing. It includes each medal awarded within the period. The dataset was
downloaded from http:
www.key2stats.com/. The original file was edited to clean the data to be
able to work with the project.
Project Overview
You will read a file to create a collection of Olympic Medalists and a collection of total medals
y country. Once you have created the collections, you will be able to ask questions like: how
many medalists do we have in the collection, find a particular Olympic medalist, search for the
Olympic medalists that participated in a specific Olympic game, find the medalists for a specific
country, find the top 10 countries with gold medals in a specific year, etc.
This project has the following classes:
 OlympicMedalist – class to handle the information about the individual
medalist
Fall XXXXXXXXXXCIS 162 Project 3 Olympic Medalists Database Page 1 of 11
https:
www.cis.gvsu.edu/academic-honesty
https:
www.cis.gvsu.edu/academic-honesty
http:
www.key2stats.com
 OlympicCountryMedals – class to handle the total gold, silver and
onze
medals for a country participating in a specific Olympic game
 OlympicMedalistDatabase – class that reads the input file and creates the
collections of medalists and medal totals
 OlympicMedalistsGUI – class that handles the GUI to read the input file, and run
the queries associated with the collection of medalists and medal totals
Create a New BlueJ Project
Download Data File
Download the “SummerOlympicsMedals.csv” file and save it in the folder that BlueJ created for
this project. There are over 15,000 records! You will not see the file within BlueJ but you can
see it from within Windows Explorer.
Coding Style (10 pts)
Good programming practice includes writing elegant source code for the human reader. Follow
the GVSU Java Style Guide.
Phase 1 (20 pts)
Important note:
Exact spelling is required for the name of the OlympicMedalist,
OlympicCountryMedals and the OlympicMadalistsDatabase classes and the
headers of all the methods within these classes. Do not make any changes to the following
equirements. If you do so, the automated tests that we provide will likely fail.
Create a class called OlympicMedalist
This class will store the data for a specific summer Olympic medalist.
Instance Variables:
 city (String)
 year (int)
 sport (String)
 discipline (String)
 event (String)
 athlete name (String)
 gender (String)
 country code (String)
 medal (String)
Fall XXXXXXXXXXCIS 162 Project 3 Olympic Medalists Database Page 2 of 11
https:
www.cis.gvsu.edu/java-coding-style-guide
Constructor
 public OlympicMedalist (String data) - a constructor that initializes all the
instance variables to appropriate values. The input parameter is a String that contains the
values of an Olympic medalist. Each value is separated by a comma. You need to parse the
string data into the individual fields. The order of the fields in the string is:
city, year, sport, discipline, event, athlete name, gender, country code and medal.
Hint: Use the split method of the string class using comma as the delimiter to parse the
string entered as input parameter into the individual fields.
Example of the data entered as input parameter.
"Montreal,1976,Aquatics,Diving,3m springboard,BOGGS Philip George,Men,USA,Gold"
Accesso
getter Methods
 public String getCity() – returns the Olympic games city
 public int getYear() – returns the Olympic games yea
 public String getSport() – returns the sport
 public String getDiscipline() – returns the discipline
 public String getEvent() – returns the event
 public String getName() – returns the athlete name
 public String getGender() – returns the athlete gende
 public String getCountryCode() – returns the athlete country code
 public String getMedal() – returns the athlete medal
Setter Methods
 You do not need to include any setters for this class.
More methods
 public String toString() - return a formatted String of an Olympic medalist. Do
not print, return a string concatenating the individual wanted fields. See example.
For example:
Montreal 1976 Country: USA Sport: Aquatics Event: 3m springboard Name: BOGGS Philip George, Gold
Create a class called OlympicCountryMedals
This class will store the total number of gold, silver and
onze medals for each country
participating in a specific Olympic game.
Instance Variables:
 city (String)
 year (int)
 country code (String)
 goldMedals (int)
Fall XXXXXXXXXXCIS 162 Project 3 Olympic Medalists Database Page 3 of 11
 silverMedals (int)

onzeMedals (int)
Constructor
 public OlympicCountryMedals(int year, String city, String countryCode,
int goldMedals,int silverMedals, int
onzeMedals) - a constructor that
initializes all the instance variables to appropriate values of the input parameters.
Accesso
getter Methods
 public String getCity() – returns the Olympic games city
 public int getYear() – returns the Olympic games yea
 public String getCountryCode() – returns the country code
 public int getGoldMedals() – returns the total gold medals
 public int getSilverMedals() – returns the total silver medals
 public int getBronzeMedals() – returns the total
onze medals
Setter Methods
 You do not need to include any setters for this class.
More methods
 public String toString() - return a formatted String of an Olympic Country
Medals. Do not print, return a string concatenating the individual wanted fields. See
example.
For example:
2008 Beijing, USA, Gold: 125, Silver: 109, Bronze: 81
Test Phase 1 using the automated JUnit class
Download the MyOlympicMedalistTestPhase1.java to the folder where you saved
your project 3 and test your solution. See instructions from project 1 to know how to run a JUnit
class.
Note: You do not need to create your own class to test phase1 of your project.
Phase 2 (50 pts)
Create a class called OlympicMedalistsDatabase
This class maintains:
 an A
ayList of OlympicMedalist objects
 an A
ayList of OlympicCountryMedals objects
Instance Variables
 Declare an A
ayList of OlympicMedalist objects
 Declare an A
ayList of OlympicCountryMedals
Fall XXXXXXXXXXCIS 162 Project 3 Olympic Medalists Database Page 4 of 11
Constructo
 public OlympicMedalistsDatabase () - instantiate the two A
ayLists declared as
instance variables.
Mutator Methods
 public void readOlympicMedalistData(String filename) - open the
provided filename given as input parameter, use a loop to read all the data in the file, create a
OlympicMedalist object for each record and add it to the A
ayList. We are providing most
of the code for this method. Look for the TO DO comment to complete the logic.
Background Information: Reading from a Text File
The readOlympicMedalistData method reads one line at the time. Each line contains
9 items that are separated by commas. This method passes the line (record) read to the
OlympicMedalist class constructor and adds the OlympicMedalist object to the A
ayList.
Sample record:
"Montreal,1976,Aquatics,Diving,3m springboard,BOGGS Philip George,Men,USA,Gold"
public void readOlympicMedalistData(String filename) {

Read the full set of data from a text file
XXXXXXXXXXtry{

open the text file and use a Scanner to read the text
XXXXXXXXXXFileInputStream fileByteStream = new FileInputStream(filename);
XXXXXXXXXXScanner scnr = new Scanner(fileByteStream);
XXXXXXXXXXscnr.nextLine();
reads the column headers

keep reading as long as there is more data
XXXXXXXXXXwhile(scnr.hasNext()) {

reads each record of the file
XXXXXXXXXXString data = scnr.nextLine();

TO DO: instantiates an object of the OlympicMedalist class

and add it to the A
ayList of OlympicMedalists

}
XXXXXXXXXXgenerateCountryTotalMedals();
This method will be written late
XXXXXXXXXXfileByteStream.close();
}
XXXXXXXXXXcatch(IOException e) {
XXXXXXXXXXSystem.out.println("Failed to read the data file: " + filename);
}
}
Accessor Methods
 public int countAllMedalists () - return the number of Olympic medalists
found in the database using one line of code.
 public int countAllWomen() – Use a for-each loop to search the full list of
Olympic medalists and count the total number of women Olympic medalists.
Fall XXXXXXXXXXCIS 162 Project 3 Olympic Medalists Database Page 5 of 11
 public int countAllMen() – Use a for-each loop to search the full list of
Olympic medalists and count the total number of men Olympic medalists.
 public A
ayList getMedalistsDatabase()-
eturn the A
ayList of OlympicMedalists. One line of code.
 public A
ayList
getCountryTotalMedalsDatabase()- return the A
ayList of
OlympicCountryMedals. One line of code.
 public A
ayList searchMedalistsByYear(int
year)– Use a for-each loop to search the full list of Olympic medalists and return a new
list of Olympic medalists for the year entered as input parameter. If there is no match for
the year, the returned list will exist but have zero elements.
Answered Same Day Dec 03, 2021

Solution

Ramachandran answered on Dec 04 2021
107 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here