forked from ashishps1/awesome-low-level-design
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAirlineManagementSystem.java
53 lines (43 loc) · 1.71 KB
/
AirlineManagementSystem.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
package airlinemanagementsystem;
import airlinemanagementsystem.booking.Booking;
import airlinemanagementsystem.booking.BookingManager;
import airlinemanagementsystem.flight.Flight;
import airlinemanagementsystem.flight.FlightSearch;
import airlinemanagementsystem.payment.Payment;
import airlinemanagementsystem.payment.PaymentProcessor;
import airlinemanagementsystem.seat.Seat;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
public class AirlineManagementSystem {
private final List<Flight> flights;
private final List<Aircraft> aircrafts;
private final FlightSearch flightSearch;
private final BookingManager bookingManager;
private final PaymentProcessor paymentProcessor;
public AirlineManagementSystem() {
flights = new ArrayList<>();
aircrafts = new ArrayList<>();
flightSearch = new FlightSearch(flights);
bookingManager = BookingManager.getInstance();
paymentProcessor = PaymentProcessor.getInstance();
}
public void addFlight(Flight flight) {
flights.add(flight);
}
public void addAircraft(Aircraft aircraft) {
aircrafts.add(aircraft);
}
public List<Flight> searchFlights(String source, String destination, LocalDate date) {
return flightSearch.searchFlights(source, destination, date);
}
public Booking bookFlight(Flight flight, Passenger passenger, Seat seat, double price) {
return bookingManager.createBooking(flight, passenger, seat, price);
}
public void cancelBooking(String bookingNumber) {
bookingManager.cancelBooking(bookingNumber);
}
public void processPayment(Payment payment) {
paymentProcessor.processPayment(payment);
}
}