Repository navigation
Expand file tree
/
Copy pathFireSandwich.java
More file actions
234 lines (182 loc) · 5.39 KB
/
Copy pathFireSandwich.java
File metadata and controls
234 lines (182 loc) · 5.39 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
//This class will represent a table
class Table
{
//Variables
public String ServerName;
public int tableNum;
public int guestNum;
public Map<Integer, guest> guest; //Store each guest with a key integer, representing each seat
private boolean ready = false;
private long createdAt; //To set when the ticket is created
//Constructors
public Table(String SN, int TN, int GN)
{
this.ServerName = SN;
this.tableNum = TN;
this.guestNum = GN;
this.ready = false;
this.createdAt = System.currentTimeMillis();
loadGuests(GN);
}
public Table() {}
//Getters
public String getServerName() {return ServerName;}
public int getTableNum() {return tableNum;}
public int getGuestNum() {return guestNum;}
public Map<Integer, guest> getGuest() {return guest;}
public boolean isReady() { return ready;}
public void setReady(boolean ready) {this.ready = ready;}
public long getCreatedAt() { return createdAt;}
//Helper methods to display menus
public static String DrinkMenu()
{
while(true)
{
System.out.println("Select a drink:");
System.out.println("1.- WATER");
System.out.println("2.- COKE");
System.out.println("3.- SWEET TEA");
int choice = FireSandwich.scan.nextInt();
switch(choice)
{
case 1: return "WATER";
case 2: return "COKE";
case 3: return "SWEAT TEA";
default:
System.out.println("Not a valid option");
}
}
}
public static String SandwichMenu()
{
while(true)
{
System.out.println("Select a Sandwich:");
System.out.println("1.- Chicken Sand");
System.out.println("2.- BBQ Chicken Sand");
System.out.println("3.- Pull Pork Sand");
System.out.println("4.- Fire House Sand");
int choice = FireSandwich.scan.nextInt();
switch(choice)
{
case 1: return "Chicken Sand";
case 2: return "BBQ Chicken Sand";
case 3: return "Pull Pork Sand";
case 4: return "Fire House Sand";
default:
System.out.println("Not a valid option");
}
}
}
public static String SideMenu()
{
while(true)
{
System.out.println("Select a Side:");
System.out.println("1.- French Fries");
System.out.println("2.- Potato Chips");
System.out.println("3.- House Salad");
int choice = FireSandwich.scan.nextInt();
switch(choice)
{
case 1: return "French Fries";
case 2: return "Potato Chips";
case 3: return "House Salad";
default:
System.out.println("Not a valid option");
}
}
}
//Helper method to fill the hashmap based on the amount of guests
public void loadGuests(int n)
{
//Declare and initialize each variable and hashmap
guest = new HashMap<>();
for(int i = 1; i <= n; i++)//based on the amount of guest
{
System.out.println();
System.out.println("SEAT "+ i);
String drink = DrinkMenu();
String sandwich = SandwichMenu();
String side = SideMenu();
guest G = new guest(drink, sandwich, side);//Creates a guest Object
guest.put(i, G); //Add it to the hashMap
}
}
}
//This Class is an object of guest
class guest
{
//Variables
String drink;
String sandwich;
String side;
//Constructors
public guest(String d, String sw, String sd)
{
this.drink = d;
this.sandwich = sw;
this.side = sd;
}
public guest() {
}
//Getters
public String getDrink() {return drink;}
public String getSandwich() {return sandwich;}
public String getSide() {return side;}
}
public class FireSandwich
{
public static Scanner scan = new Scanner(System.in);
public static void main(String[] args)
{
//Initiate connection with the Display Queue html
try {
TicketServer.start();
} catch (Exception e) {
System.out.println("Could not start HTTP server: " + e.getMessage());
}
System.out.println("-----WELCOME TO FIRE SANDWICH RESTAURANT-----");
System.out.println();
System.out.println(" OPENING THE SYSTEM...");
System.out.println();
//Declare variable
String name = null;
int table = 0;
int guestNum = 0;
char answer;
while(true)
{
System.out.println("Do you want to place an order? Y/N");
answer = scan.next().charAt(0);
if(answer == 'N' || answer == 'n')
{
System.out.println("Closing System...");
System.out.println("Have a nice day!");
TicketServer.stop();
break;
}
//Request server name, table number and number of guest to create the table
System.out.println("Please, type your name: ");
name = scan.next();
System.out.println("Please, type table number: ");
table = scan.nextInt();
System.out.println("How many guests?");
guestNum = scan.nextInt();
Table tb = new Table(name, table, guestNum); //Creates table
System.out.println();
System.out.println("Sent order? Y/N");
answer = scan.next().charAt(0);
if(answer == 'y' || answer == 'Y')
{
TicketQueueManager.addTicket(tb); //Add it to the queue
System.out.println();
}else {
System.out.println("Order NOT sent!");
}
}
}
}