World Cup Stats analyser application
You have been given a data file (WorldCupMatches.csv) that contains various details for each FIFA World Cup match from 1930 until 2014. You are tasked with writing an OOP based Java application that will enable the reading and searching of the data.
Create a project solution (named PGCert<your student id> e.g. PGCert2048201). Create a package named wc. Add WorldCupMatches.csv to the project. Ensure your name and student number are placed in the Javadoc comments of all the classes you write to support the application.
Part 1 – 50%
Using your knowledge of OOP:
1. Create a class Match.java that will represent each match detail. The class should have all the properties for each data point (attribute) of the match. Each attribute with appropriate validation rule is detailed below.
|
Attribute |
Allowable values |
|
Year |
1930 (inclusive) onwards |
|
Host |
At least 1 character but less than 30 |
|
Stage |
At least 1 character but less than 50 |
|
Stadium |
At least 1 character but less than 80 |
|
City |
At least 1 character but less than 40 |
|
Attendance |
0 – 200000 (inclusive) |
|
Home Team Name |
At least 1 character but less than 35 |
|
Home Team Goals |
0 – 15 (inclusive) |
|
Away Team Goals |
0 – 15 (inclusive) |
|
Away Team Name |
At least 1 character but less than 35 |
|
Win conditions |
ET (extra time) |
|
Half-time Home Goals |
0 – 15 (inclusive) |
|
Half-time Away Goals |
0 – 15 (inclusive) |
|
Home Team Initials |
Three characters |
|
Away Team Initials |
Three characters |
Return an appropriate exception with an appropriate exception message e.g. “Invalid Home Goals”, “Invalid team name format” etc. if an attempt is made to set outside a range or allowable values.
2. You should fully unit test this class.
1
PG Cert Programming Summer 2020
Part 2 – Searches – 50%
Create a Stats.java class is designed to support the system for searching. It should have the application’s main method and then a series of methods calls.
Methods required:
- Read each match detail from the csv, creating an instance of the Match class (from Part 1) for each match and populate this arraylist : (which should be created with the Stats class.)
public static ArrayList<Match> matches = new ArrayList<Match>(); Acting on this populated ArrayList then perform the following operations matching the format of the
example outputs…
- Output to screen all details of all matches e.g.
Match [year=2002, host=South Korea/Japan, stage=Group F, stadium=Saitama Stadium 2002, city=Saitama , attendance=52721, homeTeamName=England, homeTeamGoals=1, awayTeamGoals=1, awayTeamName=Sweden, winConditions= , halfTimeHomeGoals=1, halfTimeAwayGoals=0, homeTeamInitials=ENG, awayTeamInitials=SWE]
- Output to screen the total attendances of all matches and the average attendance (to two decimal points) for WC matches.
Total attendances in all WCs : Average attendances:
- Output to screen the results of any searched for WC year. Eg. Searching for 1998 would output :
All matches in WC France 1998 Brazil 2 : Scotland 1
Morocco 2 : Norway 2
Italy 2 : Chile 2Etc…
- Output to screen the results of any searched for country that has played in the WC e.g. Searching for Spain would output :
Matches Spain have played in the WC Spain 3 : Brazil 1
Italy 1 : Spain 1
Italy 1 : Spain 0Spain 3 : USA 1 Etc…
2
PG Cert Programming Summer 2020
- Output to screen the following details for all WC final matches
1930 Uruguay
Uruguay 4 : Argentina 21934 Italy
Italy 2 : Czechoslovakia 11938 France
Italy 4 : Hungary 2Etc…
- Output to screen the total number of goals scored in all WC matches and the average goals per game (to
two decimal places).
Total goals in all WCs : Average goals per game :
- Output the details for the matches with the smallest attendance and also the largest attendance.
Attendances
Smallest attendance 2000
Uruguay 1930 Estadio Centenario Uruguay CHI vs FRALargest attendance etc…
- Output to screen the details of each match that went to extra time (i.e. Win Condition being set as ET) e.g.
ET games
1934 Italy Preliminary round Austria 3 : France 21934 Italy Final
Italy 2 : Czechoslovakia 1 Etc… - Output to screen the details of each match that went to penalties. Win conditions either HWP or AWP e.g.
Games that went to penalties 1990 Italy Semi-finals
ITA 1 : ARG 1
Winner : ARGEtc…
3
PG Cert Programming Summer 2020
11. Output to screen the percentage of games won by the team that were leading at half time.
When complete compress (zip) the Eclipse solution and upload to Assignments on CANVAS Now : check the upload to ensure you have submitted the correct files.
[END]
4



