-
Notifications
You must be signed in to change notification settings - Fork 0
/
InstituteUI.java
125 lines (109 loc) · 3.46 KB
/
InstituteUI.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import java.util.*;
/**
* A class used to test CALM program.
* It test all scenarios that could be faced when running a
* site management situation
*
* @author Moustafa Mahmoud
* @version 9/1/2021
*/
public class InstituteUI
{
private Scanner reader = new Scanner(System.in);
private CALM corona = new Institute();
private void runUI()
{
int choice = getOption();
while (choice != 0)
{
// process choice
if (choice == 1){listAllRooms();}
else if (choice == 2){listAllPassesbyRoom();}
else if (choice == 3){listOneRoom();}
else if (choice == 4){findAPass();}
else if (choice == 5){showAPass();}
else if (choice == 6){tryMove();}
else if (choice == 7){moveNow();}
else if (choice == 8){resetAllPasses();}
// output menu & get choice
choice = getOption();
}
System.out.println("\nThank-you");
}
private int getOption()
{
System.out.println("What would you like to do ?");
System.out.println("0. Quit");
System.out.println("1. List all room details");
System.out.println("2. List all passes on each room");
System.out.println("3. List all passes on one room");
System.out.println("4. Find the current room of a pass");
System.out.println("5. Show details of a pass");
System.out.println("6. Say if pass can move through a door");
System.out.println("7. Move a pass through door");
System.out.println("8. ResetAllPasses");
System.out.println("Enter your choice");
// read choice
int option = reader.nextInt();
reader.nextLine();
return option;
}
// This one has been done for you
private void listAllRooms()
{
System.out.println(corona.toString());
}
// provide the code here
private void listAllPassesbyRoom()
{
System.out.println(corona.toString());
}
// provide the code here
private void listOneRoom()
{
System.out.println("Enter room number");
int rmNo = reader.nextInt();
System.out.println(corona.getAllPassesInRoom(rmNo));
}
// provide the code here
private void findAPass()
{
System.out.println("Enter pass id");
int ps = reader.nextInt();
System.out.println(corona.findPass(ps));
}
private void showAPass()
{
System.out.println("Enter pass id");
int ps = reader.nextInt();
System.out.println(corona.showPass(ps));
}
// provide the code here
private void tryMove()
{
System.out.println("Enter pass id");
int trav = reader.nextInt();
System.out.println("Enter door number");
int door = reader.nextInt();
System.out.println(corona.canMove(trav,door));
}
// This one has been done for you
private void moveNow()
{
System.out.println("Enter pass id");
int trav = reader.nextInt();
System.out.println("Enter door number");
int door = reader.nextInt();
System.out.println(corona.move(trav,door));
}
// This one has been done for you
private void resetAllPasses()
{
corona.resetPasses();
}
public static void main(String[] args)
{
InstituteUI xx = new InstituteUI();
xx.runUI();
}
}