-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrompt.java
More file actions
67 lines (53 loc) · 1.82 KB
/
Prompt.java
File metadata and controls
67 lines (53 loc) · 1.82 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
63
64
65
66
67
import java.util.*;
import layers.PhysicalLayer;
import layers.DataLayer;
import layers.NetworkLayer;
public class Prompt {
public void run() {
Scanner scanner = new Scanner(System.in);
while (true) {
int choice, hubs = 0;
Map<Integer, String> allDevices = new HashMap<>();
allDevices.put(0, "Hub");
allDevices.put(1, "Switch");
allDevices.put(2, "Router");
System.out.println("\n\nChoose a device ");
for (Map.Entry<Integer, String> entry : allDevices.entrySet()) {
System.out.println(entry.getKey() + 1 + ": " + entry.getValue());
}
System.out.println("\nYour choice: ");
choice = scanner.nextInt();
switch (choice) {
case 1: {
System.out.println("\nEnter the number of hubs required: ");
hubs = scanner.nextInt();
if (hubs == 1) {
PhysicalLayer p = new PhysicalLayer();
p.run();
} else {
DataLayer d = new DataLayer();
d.run(2, hubs);
}
break;
}
case 2: {
DataLayer d = new DataLayer();
d.run(1, hubs);
break;
}
case 3: {
NetworkLayer n = new NetworkLayer();
n.run();
break;
}
default:
System.out.println("Invalid Entry");
break;
}
}
}
public static void main(String[] args) {
Prompt p = new Prompt();
p.run();
}
}