Question: ( a ) Write the Python class definitions for the 2 subclasses of Booking: IndividualBooking, and GroupBooking. The IndividualBooking class has: ONE class variables: _
a Write the Python class definitions for the subclasses of Booking: IndividualBooking,
and GroupBooking.
The IndividualBooking class has:
ONE class variables: SINGLE with value as additional charge
ONE additional instance variable single bool to record whether single room is
required.
Constructor must also ensure that the customer is at least years old, before
initialising the additional instance variable with the given parameter.
raise BookingException if customer is less than years old
For cost method, return the final cost as scheduled tour cost with surcharge if
single room is required.
For addSeats method, raise BookingException with message that it is not possible
to add seats for individual booking.
The GroupBooking class has:
ONE class variables:DISCOUNT that is a Dictionary containing the group size
values and their eligible discounts.
group size or more will enjoy discount
group size or more will enjoy discount
Constructor must enforce the following rules:
raise BookingException if group size is less than
raise BookingException if all customers are less than years old
For getDiscount method, return the eligible discount by checking against the classvariable
DISCOUNT. Return if this group booking has less than customers.
For the cost method, take into consideration if the group is eligible to any discount
before computing the final cost. If group is not eligible for any discount, then the
final cost will be scheduled tour cost multiply by number of customers.
Implement the method addSeats with the following rules:
In the given list of customers parameter ensure that none of them are not
already in this booking. Otherwise, raise BookingException with appropriate
message.
Invoke the appropriate method of scheduledTour object to ensure that the
scheduledTour can still accommodate the number of customers
If yes, add the customers into this booking, and return true
Otherwise, raise BookingException with message indicating that the scheduled tour may have
reached full capacity
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
