Programming Exercise: Hockey Statistics
File Structure:
partial.json: Contains a subset of the data for testing purposes.
all.json: Contains all the NHL player stats for the 2019-20 season.
Each player entry has the following format:
1 | { |
Functionalities:
File Input:
- Ask the user for the filename (
partial.json
orall.json
). - Load the JSON data from the file.
- Ask the user for the filename (
Main Menu:
- Display the following commands to the user:
0
: quit1
: search for a player2
: teams3
: countries4
: players in team5
: players from country6
: most points7
: most goals
- Wait for user input to select a command.
- Display the following commands to the user:
Search by Name:
- Allow the user to search for a player by their name.
- Display the player’s stats in the specified format.
List Teams:
- Display all the team abbreviations in alphabetical order.
List Countries:
- Display all the country abbreviations in alphabetical order.
List Players by Points:
- List players in a specific team, ordered by points (highest to lowest).
List Players by Country:
- List players from a specific country, ordered by points (highest to lowest).
Most Successful Players by Points:
- List
n
players who’ve scored the most points. - If two players have the same score, order by number of goals (higher number first).
- List
Most Successful Players by Goals:
- List
n
players who’ve scored the most goals. - If two players have the same number of goals, order by the number of games played (lower number first).
- List
Formatting:
The printout format for a player must be as follows:
1 | Leon Draisaitl EDM 43 + 67 = 110 |
- The abbreviation for the team starts at the 22nd character.
- The
+
sign is the 30th character. - The
=
sign is the 35th character. - All fields should be right-justified with space characters.
My Solution
1 | import json |