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 2 subclasses of Booking: IndividualBooking,
and GroupBooking.
The IndividualBooking class has:
ONE class variables: _SINGLE with value as 0.5(additional 50% charge).
ONE additional instance variable _single (bool), to record whether single room is
required.
Constructor must also ensure that the customer is at least 20 years old, before
initialising the additional instance variable with the given parameter.
raise BookingException if customer is less than 20 years old
For cost method, return the final cost as scheduled tour cost with 50% 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 2 group size
values and their eligible discounts.
group size 10 or more will enjoy 10% discount
group size 6 or more will enjoy 5% discount
Constructor must enforce the following rules:
raise BookingException if group size is less than 2
raise BookingException if all customers are less than 20 years old
For getDiscount method, return the eligible discount by checking against the classvariable
_DISCOUNT. Return 0 if this group booking has less than 6 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
 (a) Write the Python class definitions for the 2 subclasses of

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!