-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
executable file
·308 lines (288 loc) · 9.17 KB
/
Main.java
File metadata and controls
executable file
·308 lines (288 loc) · 9.17 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/*
* This class provides basic user interface for the hotel management system.
* It displays a menu for the user to choose the operation they want. The
* actual operation performs is delegated to other class.
*
* Creator - Tsu-Hsin Yeh
* Modifer
* Date: Nov.11 2016
*/
import java.util.*;
public class Main {
private Scanner input = new Scanner(System.in);
private boolean isFinish = false;
private InformationProcessing info;
private BillingAccounts billing;
private Reports reports;
private ServiceRecords service;
private PrintTable printTable;
// Constructor to
public Main(){
this.info = new InformationProcessing(JDBCConnector.getConnection(), input);
this.billing = new BillingAccounts(JDBCConnector.getConnection(), input);
this.reports = new Reports(JDBCConnector.getConnection(), input);
this.service = new ServiceRecords(JDBCConnector.getConnection(), input);
this.printTable = new PrintTable(JDBCConnector.getConnection(), input);
}
public void userInterface(){
displayMenu();
while(!isFinish){
// display the operation list that the user can choose from
topLevelOperationList();
}
}
// T0: Redirect to Menu
public void topLevelOperationList(){
System.out.println("Choose one of the tasks and operations: ");
System.out.println("1.Information processing");
System.out.println("2.Maintaining Service availed records");
System.out.println("3.Maintaining Billing accounts");
System.out.println("4.Reports");
System.out.println("5.Print table");
System.out.println("6.Quit database");
promptMessage();
int option = input.nextLine().toUpperCase().charAt(0);
switch(option){
case '1': informationMenu();
break;
case '2': serviceMenu();
break;
case '3': billingMenu();
break;
case '4': reportMenu();
break;
case '5': printTableMenu();
break;
case '6':
isFinish = true;
break;
default: System.out.println("Invalid input.");
}
}
// T0.1: Print the table content
public void printTableMenu(){
System.out.println("Choose one of the table to print: ");
System.out.println("1.Hotel");
System.out.println("2.Customer");
System.out.println("3.Staff");
System.out.println("4.Room Type");
System.out.println("5.Room");
System.out.println("6.Check In");
System.out.println("7.Service Record");
System.out.println("8.Billing Account");
System.out.println("9.Reserve For");
System.out.println("10.Back");
promptMessage();
int option = Integer.parseInt(input.nextLine());
switch(option){
case 1: printTable.printHotel();
break;
case 2: printTable.printCustomer();
break;
case 3: printTable.printStaff();
break;
case 4: printTable.printRoomType();
break;
case 5: printTable.printRoom();
break;
case 6: printTable.printCheckin();
break;
case 7: printTable.printServiceRecord();
break;
case 8: printTable.printBillingAccount();
break;
case 9: printTable.printReserveFor();
break;
case 10:
break;
default: System.out.println("Invalid input.");
}
}
// T1: Information processing
public void informationMenu(){
System.out.println("Choose one of the domain:");
System.out.println("1.Staff");
System.out.println("2.Customer");
System.out.println("3.Room");
System.out.println("4.Back");
promptMessage();
int option = input.nextLine().toUpperCase().charAt(0);
switch(option){
case '1': staffMenu();
break;
case '2': customerMenu();
break;
case '3': roomMenu();
break;
case '4':
break;
default: System.out.println("Invalid input.");
}
}
// T1.1: Staff information processing
public void staffMenu(){
System.out.println("Choose one of the operation:");
System.out.println("1.Create new staff");
System.out.println("2.Update existing staff");
System.out.println("3.Delete existing staff");
System.out.println("4.Back");
promptMessage();
int option = input.nextLine().toUpperCase().charAt(0);
switch(option){
case '1': info.newStaff();
break;
case '2': info.updateStaff();
break;
case '3': info.deleteStaff();
break;
case '4':
break;
default: System.out.println("Invalid input.");
}
}
// T1.2: Customer information processing
public void customerMenu(){
System.out.println("Choose one of the operation:");
System.out.println("1.Create new customer");
System.out.println("2.Update existing customer");
System.out.println("3.Delete existing customer");
System.out.println("4.Back");
promptMessage();
int option = input.nextLine().toUpperCase().charAt(0);
switch(option){
case '1': info.newCustomer();
break;
case '2': info.updateCustomer();
break;
case '3': info.deleteCustomer();
break;
case '4':
break;
default: System.out.println("Invalid input.");
}
}
// T1.3: Room information processing
public void roomMenu(){
System.out.println("Choose one of the operation:");
System.out.println("1.Create new room");
System.out.println("2.Update existing room");
System.out.println("3.Delete existing room");
System.out.println("4.Check available room");
System.out.println("5.Assign room to customer");
System.out.println("6.Release room for customer");
System.out.println("7.Back");
promptMessage();
int option = input.nextLine().toUpperCase().charAt(0);
switch(option){
case '1': info.newRoom();
break;
case '2': info.updateRoom();
break;
case '3': info.deleteRoom();
break;
case '4': info.checkAvailability();
break;
case '5': info.assignRoom();
break;
case '6': info.releaseRoom();
break;
case '7':
break;
default: System.out.println("Invalid input.");
}
}
// T2: Maintaining service availed records
public void serviceMenu(){
System.out.println("Choose one of the operation:");
System.out.println("1.Enter phone bill");
System.out.println("2.Update phone bill");
System.out.println("3.Enter laundry bill");
System.out.println("4.Update laundry bill");
System.out.println("5.Enter restaurant bill");
System.out.println("6.Update restaurant bill");
System.out.println("7.Back");
promptMessage();
int option = input.nextLine().toUpperCase().charAt(0);
switch(option){
case '1': service.newPhoneBill();
break;
case '2': service.updatePhoneBill();
break;
case '3': service.newLaundryBill();
break;
case '4': service.updateLaundryBill();
break;
case '5': service.newRestaurantBill();
break;
case '6': service.updateRestaurantBill();
break;
case '7':
break;
default: System.out.println("Invalid input.");
}
}
// T3: Maintaining billing accounts
public void billingMenu(){
System.out.println("Choose one of the operation:");
System.out.println("1.Generate billing account");
System.out.println("2.Update billing account");
System.out.println("3.Back");
promptMessage();
int option = input.nextLine().toUpperCase().charAt(0);
switch(option){
case '1': billing.generateBillingAccount();
break;
case '2': billing.updateBillingAccount();
break;
case '3':
break;
default: System.out.println("Invalid input.");
}
}
// T4: Reports
public void reportMenu(){
System.out.println("Choose one of the operation:");
System.out.println("1.Report occupancy by \"Room type\"");
System.out.println("2.Report occupancy by \"Date range\"");
System.out.println("3.Report occupancy by \"Hotel\"");
System.out.println("4.Report occupants");
System.out.println("5.Report % room occupied");
System.out.println("6.Report staff group by \"Role\"");
System.out.println("7.Report customers given \"Catering staff\"");
System.out.println("8.Report customers given \"Service staff\"");
System.out.println("9.Back");
promptMessage();
int option = input.nextLine().toUpperCase().charAt(0);
switch(option){
case '1': reports.getOccupancyByRoomType();
break;
case '2': reports.getOccupancyByDate();
break;
case '3': reports.getOccupancyByHotel();
break;
case '4': reports.getOccupants();
break;
case '5': reports.getPercentRoomOccupied();
break;
case '6': reports.getStaffGroupByRole();
break;
case '7': reports.getCustomerByCatering();
break;
case '8': reports.getCustomerByService();
break;
case '9':
break;
default: System.out.println("Invalid input.");
}
}
public void displayMenu(){
System.out.println("Welcome to WolfVillas Hotel Database Management System.");
}
public void promptMessage(){
System.out.print(":");
}
// The entry point for the program
public static void main(String []args){
new Main().userInterface();
}
}