-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNHLStatisticsPart2.java
53 lines (45 loc) · 2.11 KB
/
NHLStatisticsPart2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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")) {
System.out.println("Which player?");
String playerName = reader.nextLine();
NHLStatistics.searchByPlayer(playerName);
// Ask the user first which player's statistics are needed and then print them.
} else if (command.equals("club")) {
System.out.println("Which club?");
String teamName = reader.nextLine();
NHLStatistics.sortByPoints();
NHLStatistics.teamStatistics(teamName);
// 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).
}
}
}
}