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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidapplyPromocode(String promocode) voidCancels 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.intgetId()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.booleanChecks if the booking is cancelled.voidsetBookingDate(LocalDate bookingDate) Sets the booking date of the booking.voidsetCustomer(Customer customer) Sets the customer associated with the booking.voidsetFlightNumber(String newFlightNumber) Sets the flight number for the outbound flight.voidsetOutboundFlight(Flight outboundFlight) Sets the outbound flight of the booking.voidsetPrice(double newPrice) Sets the price of the booking.voidsetReturnFlight(Flight returnFlight) Sets the return flight of the booking.toString()Provides a string representation of the booking.
- 
Constructor Details- 
BookingConstructs a new Booking object with only an outbound flight.- Parameters:
- customer- The customer making the booking
- outboundFlight- The outbound flight to be booked
 
- 
BookingConstructs a new Booking object with both outbound and return flights.- Parameters:
- customer- The customer making the booking
- outboundFlight- The outbound flight to be booked
- returnFlight- The return flight to be booked
 
 
- 
- 
Method Details- 
getCustomerRetrieves the customer who made the booking.- Returns:
- The customer who made the booking
 
- 
getOutboundFlightRetrieves the outbound flight of the booking.- Returns:
- The outbound flight of the booking
 
- 
getReturnFlightRetrieves the return flight of the booking.- Returns:
- The return flight of the booking, or null if not available
 
- 
getBookingDateRetrieves the date when the booking was made.- Returns:
- The date when the booking was made
 
- 
isCancelledpublic boolean isCancelled()Checks if the booking is cancelled.- Returns:
- True if the booking is cancelled, false otherwise
 
- 
setCustomerSets the customer associated with the booking.- Parameters:
- customer- The customer to be associated with the booking
 
- 
setOutboundFlightSets the outbound flight of the booking.- Parameters:
- outboundFlight- The outbound flight to be set for the booking
 
- 
setReturnFlightSets the return flight of the booking.- Parameters:
- returnFlight- The return flight to be set for the booking
 
- 
setBookingDateSets the booking date of the booking.- Parameters:
- bookingDate- The booking date to be set for the booking
 
- 
cancelBookingpublic void cancelBooking()Cancels the booking by marking it as cancelled and applying a cancellation fee.
- 
setPricepublic void setPrice(double newPrice) Sets the price of the booking.- Parameters:
- newPrice- The new price to be set for the booking
 
- 
getIdpublic int getId()Generates an ID for the booking based on the customer ID.- Returns:
- The generated booking ID
 
- 
toStringProvides a string representation of the booking.
- 
setFlightNumberSets the flight number for the outbound flight.- Parameters:
- newFlightNumber- The new flight number to be set
 
- 
getPriceRetrieves the price of the booking.- Returns:
- The price of the booking
 
- 
applyPromocode
 
-