Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 12ed7eb

Browse filesBrowse files
AirLine_management_US007
1 parent 79896cd commit 12ed7eb
Copy full SHA for 12ed7eb

File tree

Expand file treeCollapse file tree

4 files changed

+466
-0
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+466
-0
lines changed
+146Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
import java.util.*;
2+
3+
public class AMS {
4+
5+
static Scanner sc = new Scanner(System.in);
6+
static HashMap<Integer, Customer> customerMapList = new HashMap<>();
7+
static HashMap<Integer, Carrier> carrierMapList = new HashMap<>();
8+
9+
static Customer loggedInCustomer = null;
10+
11+
private static void registerCustomer() {
12+
System.out.print("Enter the user name: ");
13+
String userName = sc.nextLine();
14+
15+
System.out.print("Enter the password: ");
16+
String password = sc.nextLine();
17+
18+
System.out.print("Enter the phone: ");
19+
Long phone = sc.nextLong();
20+
sc.nextLine(); // Consume newline
21+
22+
System.out.print("Enter the email: ");
23+
String email = sc.nextLine();
24+
25+
System.out.print("Enter the address1: ");
26+
String address1 = sc.nextLine();
27+
28+
System.out.print("Enter the address2: ");
29+
String address2 = sc.nextLine();
30+
31+
System.out.print("Enter the city: ");
32+
String city = sc.nextLine();
33+
34+
System.out.print("Enter the state: ");
35+
String state = sc.nextLine();
36+
37+
System.out.print("Enter the zipcode: ");
38+
Long zipcode = sc.nextLong();
39+
sc.nextLine();
40+
41+
System.out.print("Enter the dob: ");
42+
String dob = sc.nextLine();
43+
44+
int userId = customerMapList.size() + 1;
45+
Customer newCustomer = new Customer(userId, userName, password, email, phone, address1, address2, city, state, zipcode, dob);
46+
customerMapList.put(userId, newCustomer);
47+
48+
System.out.println("Registered Successfully!\nYour User ID: " + userId);
49+
}
50+
51+
private static boolean checkValidCustomer(int userId, String password) {
52+
if (customerMapList.containsKey(userId) && customerMapList.get(userId).getPassword().equals(password)) {
53+
loggedInCustomer = customerMapList.get(userId);
54+
return true;
55+
}
56+
System.out.println("\nYou're Not Authenticated. Please Register.");
57+
return false;
58+
}
59+
60+
private static boolean login(String type) {
61+
if (type.equals("admin")) {
62+
return Admin.adminMenu();
63+
} else if (type.equals("customer")) {
64+
System.out.print("-------------------------------------------------------------------");
65+
System.out.print("\nEnter the userId: ");
66+
int userId = sc.nextInt();
67+
sc.nextLine(); // Consume newline
68+
69+
System.out.print("Enter the password: ");
70+
String password = sc.nextLine();
71+
System.out.print("-------------------------------------------------------------------");
72+
73+
if (checkValidCustomer(userId, password)) {
74+
return Customer.customerMenu();
75+
}
76+
}
77+
return false;
78+
}
79+
80+
private static void displayCustomers() {
81+
if (customerMapList.isEmpty()) {
82+
System.out.println("\nNo Customers Registered Yet.");
83+
} else {
84+
System.out.println("\nList of Customers:");
85+
for (Map.Entry<Integer, Customer> map : customerMapList.entrySet()) {
86+
System.out.println(
87+
"User ID: " + map.getValue().getUserId() +
88+
" | Name: " + map.getValue().getUserName()
89+
);
90+
}
91+
}
92+
}
93+
94+
public static void main(String[] args) {
95+
// Adding default customers
96+
customerMapList.put(1, new Customer(1, "pradeep", "krish", "pradeep@gmail.com",
97+
987654322L, "south", "murukanathapuram", "karur", "tamil", 639001L, "24/4/2002"));
98+
99+
customerMapList.put(2, new Customer(2, "pradeep2", "krish2", "pradeep2@gmail.com",
100+
987654322L, "north", "somewhere", "chennai", "tamil", 600001L, "25/5/2003"));
101+
102+
int n;
103+
do {
104+
System.out.println("\n-------------------------------------------------------------------");
105+
System.out.println("1. Admin Sign-in");
106+
System.out.println("2. Customer Sign-in");
107+
System.out.println("3. Customer Registration");
108+
System.out.println("4. Display Customer List");
109+
System.out.println("5. Exit");
110+
System.out.println("-------------------------------------------------------------------");
111+
System.out.print("Enter the operation: ");
112+
113+
n = sc.nextInt();
114+
sc.nextLine(); // Consume newline
115+
116+
switch (n) {
117+
case 1:
118+
System.out.println("Admin sign-in");
119+
if (login("admin")) System.exit(0);
120+
break;
121+
122+
case 2:
123+
System.out.println("Customer sign-in");
124+
if (login("customer")) System.exit(0);
125+
break;
126+
127+
case 3:
128+
System.out.println("Customer Registration");
129+
registerCustomer();
130+
break;
131+
132+
case 4:
133+
displayCustomers();
134+
break;
135+
136+
case 5:
137+
System.out.println("Exiting the program...");
138+
System.exit(0);
139+
break;
140+
141+
default:
142+
System.out.println("Invalid choice, please try again.");
143+
}
144+
} while (true);
145+
}
146+
}
+156Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
import java.util.*;
2+
3+
public class Admin extends AMS {
4+
static Scanner sc = new Scanner(System.in);
5+
6+
public static void createCarrier() {
7+
System.out.print("Enter the Carrier Name: ");
8+
String carrierName = sc.nextLine().trim();
9+
10+
System.out.print("Enter Discount for 30 Days Advance Booking: ");
11+
int discount30Days = sc.nextInt();
12+
13+
System.out.print("Enter Discount for 60 Days Advance Booking: ");
14+
int discount60Days = sc.nextInt();
15+
16+
System.out.print("Enter Discount for 90 Days Advance Booking: ");
17+
int discount90Days = sc.nextInt();
18+
19+
System.out.print("Enter Bulk Booking Discount: ");
20+
int bulkBooking = sc.nextInt();
21+
22+
System.out.print("Enter Refund for Ticket Cancellation (2 Days Before): ");
23+
int refund2Days = sc.nextInt();
24+
25+
System.out.print("Enter Refund for Ticket Cancellation (10 Days Before): ");
26+
int refund10Days = sc.nextInt();
27+
28+
System.out.print("Enter Refund for Ticket Cancellation (20 Days Before): ");
29+
int refund20Days = sc.nextInt();
30+
31+
System.out.print("Enter Silver User Discount: ");
32+
int silverDiscount = sc.nextInt();
33+
34+
System.out.print("Enter Gold User Discount: ");
35+
int goldDiscount = sc.nextInt();
36+
37+
System.out.print("Enter Platinum User Discount: ");
38+
int platinumDiscount = sc.nextInt();
39+
try {
40+
int carrierId = carrierMapList.size() + 1;
41+
42+
Carrier newCarrier = new Carrier(carrierId, carrierName, discount30Days, discount60Days, discount90Days,
43+
bulkBooking,
44+
refund2Days, refund10Days, refund20Days, silverDiscount, goldDiscount, platinumDiscount);
45+
carrierMapList.put(carrierId, newCarrier);
46+
System.out.println("Carrier Added Successfully");
47+
} catch (Exception e) {
48+
System.out.println("Encountered issue while saving carrier information. Please check the data and try again");
49+
}
50+
}
51+
52+
public static void editCarrier() {
53+
System.out.print("Enter Carrier ID: ");
54+
int carrierId = sc.nextInt();
55+
sc.nextLine();
56+
57+
if (!carrierMapList.containsKey(carrierId))
58+
System.out
59+
.println("Either the data is incorrect or no Carrier informationis availabe for tha given Ca rrier ID ");
60+
61+
System.out.print("Enter new Carrier Name: ");
62+
String carrierName = sc.nextLine();
63+
64+
System.out.print("Enter new Discount for 30 Days Advance Booking: ");
65+
int discount30Days = sc.nextInt();
66+
67+
System.out.print("Enter new Discount for 60 Days Advance Booking: ");
68+
int discount60Days = sc.nextInt();
69+
70+
System.out.print("Enter new Discount for 90 Days Advance Booking: ");
71+
int discount90Days = sc.nextInt();
72+
73+
System.out.print("Enter new Bulk Booking Discount: ");
74+
int bulkBooking = sc.nextInt();
75+
76+
System.out.print("Enter new Refund for Ticket Cancellation (2 Days Before): ");
77+
int refund2Days = sc.nextInt();
78+
79+
System.out.print("Enter new Refund for Ticket Cancellation (10 Days Before): ");
80+
int refund10Days = sc.nextInt();
81+
82+
System.out.print("Enter new Refund for Ticket Cancellation (20 Days Before): ");
83+
int refund20Days = sc.nextInt();
84+
85+
System.out.print("Enter new Silver User Discount: ");
86+
int silverDiscount = sc.nextInt();
87+
88+
System.out.print("Enter new Gold User Discount: ");
89+
int goldDiscount = sc.nextInt();
90+
91+
System.out.print("Enter new Platinum User Discount: ");
92+
int platinumDiscount = sc.nextInt();
93+
try {
94+
Carrier newCarrier = new Carrier(carrierId, carrierName, discount30Days, discount60Days, discount90Days,
95+
bulkBooking,
96+
refund2Days, refund10Days, refund20Days, silverDiscount, goldDiscount, platinumDiscount);
97+
carrierMapList.put(carrierId, newCarrier);
98+
System.out.println("Carrier Added Successfully");
99+
} catch (Exception e) {
100+
System.out.println("Encountered issue while saving carrier information. Please check the data and try again");
101+
}
102+
}
103+
104+
public static void displayCarrier() {
105+
if (carrierMapList.isEmpty()) {
106+
System.out.println("\nNo Customers Registered Yet.");
107+
} else {
108+
System.out.println("\nList of Customers:");
109+
for (Map.Entry<Integer, Carrier> map : carrierMapList.entrySet()) {
110+
System.out.println(
111+
"Carrier ID: " + map.getValue().getCarrierId() +
112+
" | Name: " + map.getValue().getCarrierName()
113+
);
114+
}
115+
}
116+
}
117+
118+
public static boolean adminMenu() {
119+
int choose_menu = 0;
120+
do {
121+
System.out.print("-------------------------------------------------------------------");
122+
System.out.print(
123+
"\nAdmin Menu\n1.Add Carrier\n2.Edit Carrier Details by CarrierId\n3.Remove Carrier by Id\n4.Flight Cancellation - Refund Price Calculation\n5.Exit Admin\n6.Exit AMS");
124+
System.out.print("\n-------------------------------------------------------------------");
125+
System.out.print("\nEnter the operation : ");
126+
choose_menu = sc.nextInt();
127+
sc.nextLine();
128+
switch (choose_menu) {
129+
case 1:
130+
System.out.println("Add Carrier");
131+
createCarrier();
132+
break;
133+
case 2:
134+
System.out.println("Edit Carrier Details by CarrierId");
135+
editCarrier();
136+
break;
137+
case 3:
138+
System.out.println("Remove Carrier by Id");
139+
break;
140+
case 4:
141+
System.out.println("Flight Cancellation - Refund Price Calculation");
142+
displayCarrier();
143+
break;
144+
case 5:
145+
System.out.println("Exit Admin");
146+
break;
147+
case 6:
148+
System.out.println("Exit AMS");
149+
return true;
150+
default:
151+
System.out.print("Invalid");
152+
}
153+
} while (choose_menu != 5);
154+
return false;
155+
}
156+
}
+45Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
public class Carrier {
2+
private int carrierId;
3+
private String carrierName;
4+
private int discountPercentageThirtyDaysAdvanceBooking;
5+
private int discountPercentageSixtyDaysAdvanceBooking;
6+
private int discountPercentageNinetyDaysAdvanceBooking;
7+
private int bulkBookingDiscount;
8+
private int refundPercentageForTicketCancelling2DayBeforeTravelDate;
9+
private int refundPercentageForTicketCancelling10DayBeforeTravelDate;
10+
private int refundPercentageForTicketCancelling20DayBeforeTravelDate;
11+
private int silverUserDiscount;
12+
private int goldUserDiscount;
13+
private int platinumUserDiscount;
14+
15+
public Carrier(int carrierId, String carrierName, int discountPercentageThirtyDaysAdvanceBooking,
16+
int discountPercentageSixtyDaysAdvanceBooking,
17+
int discountPercentageNinetyDaysAdvanceBooking,
18+
int bulkBookingDiscount,
19+
int refundPercentageForTicketCancelling2DayBeforeTravelDate,
20+
int refundPercentageForTicketCancelling10DayBeforeTravelDate,
21+
int refundPercentageForTicketCancelling20DayBeforeTravelDate,
22+
int silverUserDiscount,
23+
int goldUserDiscount,
24+
int platinumUserDiscount) {
25+
this.carrierId = carrierId;
26+
this.carrierName = carrierName;
27+
this.discountPercentageThirtyDaysAdvanceBooking = discountPercentageThirtyDaysAdvanceBooking;
28+
this.discountPercentageSixtyDaysAdvanceBooking = discountPercentageSixtyDaysAdvanceBooking;
29+
this.discountPercentageNinetyDaysAdvanceBooking = discountPercentageNinetyDaysAdvanceBooking;
30+
this.bulkBookingDiscount = bulkBookingDiscount;
31+
this.refundPercentageForTicketCancelling2DayBeforeTravelDate = refundPercentageForTicketCancelling2DayBeforeTravelDate;
32+
this.refundPercentageForTicketCancelling10DayBeforeTravelDate = refundPercentageForTicketCancelling10DayBeforeTravelDate;
33+
this.refundPercentageForTicketCancelling20DayBeforeTravelDate = refundPercentageForTicketCancelling20DayBeforeTravelDate;
34+
this.silverUserDiscount = silverUserDiscount;
35+
this.goldUserDiscount = goldUserDiscount;
36+
this.platinumUserDiscount = platinumUserDiscount;
37+
}
38+
39+
public int getCarrierId() {
40+
return carrierId;
41+
}
42+
public String getCarrierName() {
43+
return carrierName;
44+
}
45+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.