-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
62 lines (55 loc) · 1.88 KB
/
Main.java
File metadata and controls
62 lines (55 loc) · 1.88 KB
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
54
55
56
57
58
59
60
61
62
import java.util.*;
public class Main {
public static void main(String[] args) {
Service service = new Service();
List<String> menuOptions = Arrays.asList(
"Leaderboard",
"Employees from Team",
"Add Employee",
"Remove Employee",
"See Cars",
"Add Car",
"See Sponsors",
"Add Sponsor",
"See Team Income",
"See Circuits",
"Change Circuit Best Time",
"Show Team Collection",
"Exit"
);
List<Runnable> actions = Arrays.asList(
service::printTeams,
service::printEmployees,
service::addEmployee,
service::removeEmployee,
service::printCars,
service::addCar,
service::printSponsors,
service::addSponsor,
service::totalSponsor,
service::printCircuits,
service::improveBest,
service::showTeamsCollection,
() -> {
System.out.println("Exiting...");
System.exit(0);
}
);
try (Scanner scanner = new Scanner(System.in)) {
while (true) {
System.out.println("\n============");
for (int i = 0; i < menuOptions.size(); i++) {
System.out.printf("%d. %s%n", i + 1, menuOptions.get(i));
}
System.out.print("Your choice: ");
int choice = scanner.nextInt();
scanner.nextLine();
if (choice >= 1 && choice <= menuOptions.size()) {
actions.get(choice - 1).run();
} else {
System.out.println("Invalid choice, try again!");
}
}
}
}
}