Package bcu.cmp5332.bookingsystem.model
Class Booking
java.lang.Object
bcu.cmp5332.bookingsystem.model.Booking
Represents a booking made by a customer for one or more flights.
A booking can have an outbound flight and optionally a return flight.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
applyPromocode
(String promocode) void
Cancels the booking by marking it as cancelled and applying a cancellation fee.Retrieves the date when the booking was made.Retrieves the customer who made the booking.int
getId()
Generates an ID for the booking based on the customer ID.Retrieves the outbound flight of the booking.getPrice()
Retrieves the price of the booking.Retrieves the return flight of the booking.boolean
Checks if the booking is cancelled.void
setBookingDate
(LocalDate bookingDate) Sets the booking date of the booking.void
setCustomer
(Customer customer) Sets the customer associated with the booking.void
setFlightNumber
(String newFlightNumber) Sets the flight number for the outbound flight.void
setOutboundFlight
(Flight outboundFlight) Sets the outbound flight of the booking.void
setPrice
(double newPrice) Sets the price of the booking.void
setReturnFlight
(Flight returnFlight) Sets the return flight of the booking.toString()
Provides a string representation of the booking.
-
Constructor Details
-
Booking
Constructs a new Booking object with only an outbound flight.- Parameters:
customer
- The customer making the bookingoutboundFlight
- The outbound flight to be booked
-
Booking
Constructs a new Booking object with both outbound and return flights.- Parameters:
customer
- The customer making the bookingoutboundFlight
- The outbound flight to be bookedreturnFlight
- The return flight to be booked
-
-
Method Details
-
getCustomer
Retrieves the customer who made the booking.- Returns:
- The customer who made the booking
-
getOutboundFlight
Retrieves the outbound flight of the booking.- Returns:
- The outbound flight of the booking
-
getReturnFlight
Retrieves the return flight of the booking.- Returns:
- The return flight of the booking, or null if not available
-
getBookingDate
Retrieves the date when the booking was made.- Returns:
- The date when the booking was made
-
isCancelled
public boolean isCancelled()Checks if the booking is cancelled.- Returns:
- True if the booking is cancelled, false otherwise
-
setCustomer
Sets the customer associated with the booking.- Parameters:
customer
- The customer to be associated with the booking
-
setOutboundFlight
Sets the outbound flight of the booking.- Parameters:
outboundFlight
- The outbound flight to be set for the booking
-
setReturnFlight
Sets the return flight of the booking.- Parameters:
returnFlight
- The return flight to be set for the booking
-
setBookingDate
Sets the booking date of the booking.- Parameters:
bookingDate
- The booking date to be set for the booking
-
cancelBooking
public void cancelBooking()Cancels the booking by marking it as cancelled and applying a cancellation fee. -
setPrice
public void setPrice(double newPrice) Sets the price of the booking.- Parameters:
newPrice
- The new price to be set for the booking
-
getId
public int getId()Generates an ID for the booking based on the customer ID.- Returns:
- The generated booking ID
-
toString
Provides a string representation of the booking. -
setFlightNumber
Sets the flight number for the outbound flight.- Parameters:
newFlightNumber
- The new flight number to be set
-
getPrice
Retrieves the price of the booking.- Returns:
- The price of the booking
-
applyPromocode
-