Last active
May 24, 2017 05:19
-
-
Save wannabecoding/429ce494e8dafcab575a218f96ae95be to your computer and use it in GitHub Desktop.
NHLStatistics Part 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import nhlstats.NHLStatistics; | |
public class NhlStatisticsPart2 { | |
public static void main(String[] args) { | |
Scanner reader = new Scanner(System.in); | |
System.out.println("NHL statistics service"); | |
while (true) { | |
System.out.println(""); | |
System.out.print("command (points, goals, assists, penalties, player, club, quit): "); | |
String command = reader.nextLine(); | |
if (command.equals("quit")) { | |
break; | |
} | |
if (command.equals("points")) { | |
NHLStatistics.sortByPoints(); | |
NHLStatistics.top(10); | |
// Print the top ten players sorted by points. | |
} else if (command.equals("goals")) { | |
NHLStatistics.sortByGoals(); | |
NHLStatistics.top(10); | |
// Print the top ten players sorted by goals. | |
} else if (command.equals("assists")) { | |
NHLStatistics.sortByAssists(); | |
NHLStatistics.top(10); | |
// Print the top ten players sorted by assists. | |
} else if (command.equals("penalties")) { | |
NHLStatistics.sortByPenalties(); | |
NHLStatistics.top(10); | |
// Print the top ten players sorted by penalties. | |
} else if (command.equals("player")) { | |
Scanner playerReader = new Scanner(System.in); | |
String player = reader.nextLine(); | |
NHLStatistics.searchByPlayer(player); | |
// Ask the user first which player's statistics are needed and then print them. | |
} else if (command.equals("club")) { | |
Scanner clubReader = new Scanner(System.in); | |
String club = reader.nextLine(); | |
NHLStatistics.sortByPoints(); | |
NHLStatistics.teamStatistics(club); | |
// Ask the user first which club's statistics are needed and then print them. | |
// Note: When printing statistics they should be ordered by points (so the players with the most points come first). | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment