-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMain.java
executable file
·94 lines (88 loc) · 4.54 KB
/
Main.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
import com.google.gson.Gson;
import controllers.BookingController;
import tools.*;
public class Main {
public static void main(String[] args) throws Exception {
Byte choice;
BookingController controller = Storage.loadData();
for (;;) {
System.out.println("");
System.out.println(
"####################################### Welcome to the flight ticket purchase system! ########################################");
System.out.println();
System.out.println(
"------------------------------------------------------------------------------------------------------------------------------");
System.out.println(
"-------------------------------------------------- 1. List All Flights -------------------------------------------------------");
System.out.println(
"-------------------------------------------------- 2. Add Flight -------------------------------------------------------------");
System.out.println(
"-------------------------------------------------- 3. Edit A Flight ---------------------------------------------------------");
System.out.println(
"-------------------------------------------------- 4. Delete Flight ----------------------------------------------------------");
System.out.println(
"-------------------------------------------------- 5. Search For A flight ----------------------------------------------------");
System.out.println(
"-------------------------------------------------- 6. Book A Ticket ----------------------------------------------------------");
System.out.println(
"-------------------------------------------------- 7. Edit A Ticket ----------------------------------------------------------");
System.out.println(
"-------------------------------------------------- 8. List All Ticket --------------------------------------------------------");
System.out.println(
"-------------------------------------------------- 9. Print A Ticket --------------------------------------------------------");
System.out.println(
"-------------------------------------------------- 10. Cancel A Ticket -------------------------------------------------------");
System.out.println(
"-------------------------------------------------- 11. Exit The System And Save ----------------------------------------------");
System.out.println(
"------------------------------------------------------------------------------------------------------------------------------");
System.out.print("Please select the serial number to be operated:");
choice = Helper.scan.nextByte();
switch (choice) {
case 1:
controller.displayFlightsDetails();
break;
case 2:
controller.addFlight();
break;
case 3:
controller.editFlight();
break;
case 4:
controller.deleteFlight();
break;
case 5:
controller.searchForFlight();
break;
case 6:
controller.bookTicket();
break;
case 7:
controller.editTicket();
break;
case 8:
controller.displayTickets();
break;
case 9:
controller.printTicket();
break;
case 10:
controller.cancelTicket();
break;
case 11:
Gson gson = new Gson();
String data = gson.toJson(controller);
if (Storage.savingData(data)) {
System.out.println("Success...");
return;
} else {
System.out.println("Something went wrong !!! plz try again...");
break;
}
default:
System.out.println("You've enter the wrong number!!!");
break;
}
}
}
}