-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamsFlightBooking.java
126 lines (96 loc) · 7.82 KB
/
amsFlightBooking.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
126
package amsSystem;
import java.util.Scanner;
public class amsFlightBooking extends amsFirstClassSeats {
//Method used to initiate Booking of a Flight and takes in multiple important parameters
public static void FlightBooking(amsFlightPackage FLight, long numberOfEconomySeats, long numberOfBusinessSeats, long numberOfFirstClassSeats) {
Scanner userCommunication = new Scanner(System.in);
System.out.println("Your Booking Process for Flight" + " " + FLight + " " + "is Starting");
System.out.println("If you would like to cancel please press 0, otherwise press any other character on your keyboard");
//Logic statement to start the booking process alongside a scanner method to take user input
if (userCommunication.next().equalsIgnoreCase("0")) {
System.out.println("Your Booking Process is Cancelled, You will return to the Home Screen");
} else {
System.out.println("For Confirmation Your Seat choices are:");
System.out.println("Number of Economy Seats:" + " " + numberOfEconomySeats);
System.out.println("Number of Business Seats:" + " " + numberOfBusinessSeats);
System.out.println("Number of First Class Seats:" + " " + numberOfFirstClassSeats);
System.out.println("If any of this information is wrong, or you want to cancel please press 0, otherwise press any other character on your keyboard");
//Another logic statement to allow users to cancel or continue booking
//Also allows users to change their seat preferences if they would like
if (userCommunication.next().equalsIgnoreCase("0")) {
System.out.println("If you would like to return to the Home Screen and Cancel, Please press 0 Again");
System.out.println("If you would like to change your seat selection please press any other character on your keyboard");
//This logic statement if they want to change their seats selected
if (userCommunication.next().equalsIgnoreCase("0")) {
System.out.println("You will be taken to the Home Screen");
} else {
System.out.println("You many now enter your new seat selection");
System.out.println("Please enter your new seat selection for Number of Economy Seats");
numberOfEconomySeats = userCommunication.nextInt();
System.out.println("Please enter your new seat selection for Number of BusinessSeats");
numberOfBusinessSeats = userCommunication.nextInt();
System.out.println("Please enter your new seat selection for Number of First Class Seats");
numberOfFirstClassSeats = userCommunication.nextInt();
System.out.println("Thank you for your Booking for flight" + " " + FLight);
System.out.println("You will now be directed to Flight Payment");
//Start of Payment, updating flight availabity by taking away booked seats in the system
FLight.setAvailableEconomySeats(FLight.getAvailableEconomySeats() - numberOfEconomySeats);
FLight.setAvailableBusinessSeats(FLight.getAvailableBusinessSeats() - numberOfBusinessSeats);
FLight.setAvailableFirstClassSeats(FLight.getAvailableFirstClassSeats() - numberOfFirstClassSeats);
//Calculating total price for the user
double totalEconomyPrice = FLight.getEconomyPrice() * numberOfEconomySeats;
double totalBusinessPrice = FLight.getBusinessPrice() * numberOfBusinessSeats;
double totalFirstClassPrice = FLight.getFirstClassPrice() * numberOfFirstClassSeats;
double totalFlightPrice = totalEconomyPrice + totalBusinessPrice + totalFirstClassPrice;
System.out.println("Your final Flight Price is" + " " + totalFlightPrice);
System.out.println("If you would like to cancel payment process and booking, press 0, Otherwise you may press any other character");
//User enters card number and other checkout options
if (userCommunication.next().equalsIgnoreCase("0")) {
System.out.println("Your Payment Process and Booking are cancelled, you will now return to the Home Screen");
}
else {
System.out.println("Please enter your First Name");
String customerName = userCommunication.next();
System.out.println("Hello" + " " + customerName);
System.out.println("Please enter you Card Number");
System.out.println("Your Card Number is:" + " " + userCommunication.nextLong());
System.out.println("Enter your CVV Number here");
System.out.println("Your CVV Number is:" + " " + userCommunication.nextInt());
System.out.println("Enter Card Expiry Date here (MM/YYYY)");
System.out.println("Your Card Expiry Date is:" + " " + userCommunication.next());
System.out.println("Thank you, your flight of" + " " + FLight + " " + "Has been Purchased and Booked");
}
}
//If they did not want to change their seat selection then follow this logic portion here
//Process for payment is the same, however the system does not ask for your new seat preferences
} else {
System.out.println("Thank you for your Booking for flight" + " " + FLight);
System.out.println("You will now be directed to Flight Payment");
FLight.setAvailableEconomySeats(FLight.getAvailableEconomySeats() - numberOfEconomySeats);
FLight.setAvailableBusinessSeats(FLight.getAvailableBusinessSeats() - numberOfBusinessSeats);
FLight.setAvailableFirstClassSeats(FLight.getAvailableFirstClassSeats() - numberOfFirstClassSeats);
double totalEconomyPrice = FLight.getEconomyPrice() * numberOfEconomySeats;
double totalBusinessPrice = FLight.getBusinessPrice() * numberOfBusinessSeats;
double totalFirstClassPrice = FLight.getFirstClassPrice() * numberOfFirstClassSeats;
double totalFlightPrice = totalEconomyPrice + totalBusinessPrice + totalFirstClassPrice;
System.out.println("Your final Flight Price is" + " " + totalFlightPrice);
System.out.println("If you would like to cancel payment process and booking, press 0, Otherwise you may press any other character");
if (userCommunication.next().equalsIgnoreCase("0")) {
System.out.println("Your Payment Process and Booking are cancelled, you will now return to the Home Screen");
}
else {
System.out.println("Please enter your First Name");
String customerName = userCommunication.next();
System.out.println("Hello" + " " + customerName);
System.out.println("Please enter you Card Number");
System.out.println("Your Card Number is:" + " " + userCommunication.nextLong());
System.out.println("Enter your CVV Number here");
System.out.println("Your CVV Number is:" + " " + userCommunication.nextInt());
System.out.println("Enter Card Expiry Date here (MM/YYYY)");
System.out.println("Your Card Expiry Date is:" + " " + userCommunication.next());
System.out.println("Thank you, your flight of" + " " + FLight + " " + "Has been Purchased and Booked");
}
}
}
}
}