A tour agency needs to track the tours it has scheduled, the bookings made for them and the passengers that the bookings are for.
(a) The tour agency organises tours. Test data for three tours is given in Table Q1.1 below:
Tour Code | Tour Name | Number of Days | Number of Nights | Cost($) |
---|---|---|---|---|
JA312 | Food Trail in Tokyo | 7 | 6 | 1999.14 |
K0111 | Discover Korea | 8 | 7 | 1449.36 |
VI102 | Vietname Highlights | 5 | 4 | 999.75 |
Implement the class Tour which has
i) the instance variables for the following pieces of data:
ii) methods:
Here is an example in the required format:
Code: K0111 Name: Discover Korea 8D/7N Base Cost: $1449.36
(b) The tour agency schedules tours to depart during peak or normal period. Test data for five scheduled tours is given in Table Q1.2 below:
Type of Schedule | Scheduled for Tour with tour code | Schedule Code | Language | Departure Date and time | Capacity | Available Seats | Is Open |
---|---|---|---|---|---|---|---|
Normal | JA312 | 1 | English | 5 Nov 2018 3.30 pm | 35 | 9 | no |
JA312 | 2 | Mandarin | 15 Jan 2019 10.45 am | 25 | 25 | yes | |
VI102 | 5 | English | 24 Feb 2019 3.15 pm | 35 | 35 | Yes | |
Peak | KO111 | 6 | Mandarin | 15 Dec 2018 1.30 am | 50 | 45 | yes |
KO111 | 2 | English | 15 Dec 2018 3.15 pm | 35 | 10 | yes |
Each scheduled tour is identified by the tour code of the tour it is scheduled for, appended with the schedule code and separated by a hyphen, e.g., JA321-1 for the tour scheduled that departs on 5 Nov 2018 at 3.30 pm.
Different languages (English, Mandarin, Malay, Tamil etc.,) may be used to conduct the same tour departing either on the same or different departure dates. When a tour is scheduled to depart during peak period, a surcharge of 25% of the tour cost applies. A booking can be made for a scheduled tour if it is open and if there are available seats. The number of available seats is decreased accordingly.
Implement the Scheduled Tour and Peak ScheduledTour, a subclass of ScheduledTour. A Peak Scheduled Tour is a Scheduled Tour that departs during a peak period and incurs a surcharge of 25% of the tour cost.
i)The superclass ScheduledTour has the following members:
- the instance variables for the following pieces of data
- methods:
Days before start of tour | Penalty per seat |
---|---|
46 days and beyond | 10% of tour cost |
Within 35 days | 25% of tour cost |
Within 20 days | 50% of tour cost |
Within 7 days | 100% of tour cost |
Any cancellation after the tour has started will incur a penalty rate of 100%.
Here is an example in the required format:
JA312 Name: Food Trail in Tokyo 7D/6N Base Cost: $1999.14
Code: 1A312-1 Language: English Departure: 5 Nov 2018 15:30 Capacity: 35 Available: 9 Open: No
ii) The class PeakScheduledTour is a subclass of Scheduled Tour. The class has the same instance variables and methods as ScheduledTour.
In addition, the class Peak Scheduled Tour has the following members:
The handling fee for cancellation a seat is $200 instead of $120.
There are differences in the implementation of the methods in the subclass Peak Scheduled Tour as compared to the methods in ScheduledTour.
Code: K0011 : Discover Korea 3D/7N Base Cost: $1449.36
Schedule Code: 0111-6 Language: Mandarin Departure: 15 Dec 2818 81:38 Capacity: 30 Available: 25 Open: Yes Cost: $1811.70 ($362.34 peak surcharge applies)
(c) Before making a tour booking, the customer must register. The details for registration include passport number, name, as well as contact and address. Once registered, to make bookings, he needs to supply only his passport number
Test data for five customers is given in Table Q1.4 below:
Passport Number | Name | Contact | Address |
---|---|---|---|
E1234567X | Alice Lee | 98989898 | 27F Sea Avenue |
E7777777X | Peter Tam | 97777777 | 8A Gray Lane |
E2323232Y | Joy Seetoh | 89898989 | 15 Sandy Lane |
E1111111Y | Mary Tham | 85858585 | 16 Jalan Mydi |
E9999999Y | Sally Koh | 87878787 | 1 Joo Heng Road |
Implement the class Customer which has the following members:
i) the instance variables for the following pieces of data:
ii) method:
Here is an example in the required format:
port Number: E2323232Y Name: Joy Seetoh Contact: 89898989 Address: 15 Sandy Lane
(d) When making a tour booking the customer must indicate whether the booking is for an individual or for a group
If the customer makes an individual booking, he can decide whether he wishes to stay in a single room. If so, he is required to pay an additional 50% of the cost of the selected scheduled tour.
If he makes a group booking, he must enter the size of his group. Each passenger in the group gets a 5% discount if the group size is between 6 and 9, and 10% if the group size is 10 or above.
Each booking has a booking id which is generated by the application. The booking id is a running number starting from 1, with an increment of 1.
Test data for eight bookings is given in Table Q1.5 below:
Type of Booking | Booked for Customer with Passport Scheduled | Customer with Passport Number | Single Room? | Size of Group |
---|---|---|---|---|
Individual | JA312-2 | E1234567X | yes | - |
Individual | JA312-2 | E7777777X | no | - |
Group | JA312-2 | E2323232Y | - | 9 |
Individual | KO111-6 | E1234567X | yes | |
Individual | KO111-6 | E7777777X | no | - |
Group | KO111-6 | E7777777X | - | 5 |
Group | KO111-6 | E2323232Y | - | 6 |
Group | KO111-6 | E1111111Y | - | 10 |
Implement the abstract class Booking and its subclasses, IndividualBooking and GroupBooking.
i) The abstract superclass Booking has the following members:
- the instance variables for the following pieces of data
The constructor of Booking accepts a scheduled tour, a customer and the number of seats for a booking. The member of seats should be used to update the seats available in the scheduled tour.
The booking id is auto-generated using a class variable whose value is incremented with each Booking object.
- methods
Booking Id: 0000000001
Passport Number: E1234567X Name: Alice Lee Contact: 98989898 Address: 27F Sea Avenue
Booked Code: JA312 Name: Food Trail in Toyko 7D/6N Base Cost: $1999.14
Schedule Code: JA312-1 Language: English Departure: 5 Nov 2018 15:38 Capacity: 35 Available: 7 Open: No
ii) The subclass IndividualBooking of Booking has the same instance variables and methods of its superclass, Booking. In addition, it has the following members:
Here are some examples in the required format:
Booking Id: 0000000001
Passport Number: E1234567X Name: Alice Lee Contact: 98989898 Address: 27F Sea Avenue
Booked Code: JA312 Name: Food Trail in Toyko 7D/6N Base Cost: $1999.14
Schedule Code: JA312-1 Language: English Departure: 5 Nov 2018 15:30 Capacity: 35 Available: 7 Open: No
Final Cost per pax: $2998.71 $999.57 Single room surcharge)
Booking Id: 0000000002
Passport Number: E7777777X Name: Peter Tan Contact: 97777777 Address: 8A Gray Lane
Booked Code: JA312 Name: Food Trail in Toyko 7D/ 6N Base Cost: $1999.14
Schedule Code: JA312-1 Language: English Departure: 5 Nov 2018 15:39 Capacity: 35 Available: 7 Open: No
Final Cost per pax: $1999.14 (No single room surcharge)
iii) The subclass GroupBooking of Booking has the same instance variables and methods of its superclass, Booking. In addition, it has the following members:
e) Implement the tour agency class that has the following members:
- the instance variables for the following pieces of data:
-methods:
f) Write an application to allow the tour agency staff to manage bookings through this menu:
Menu
1. Add Booking
2. Cancel Booking
3. Add Seats to Booking
4. Remove Seats from Booking
5. Display Booking
0. Exit
Option 1: Add booking
After the customer's passport number is entered, a scheduled tour can be chosen from the list of scheduled tours that are open A booking can be made either for an individual or for a group. The booking detail is then displayed. If the passport number or the code of the scheduled tour is invalid or if the quantity to book is more than the available seats, an appropriate error message is displayed. Otherwise, the details of the booking is displayed.
A sample interaction for option 1 is shown here: see image.
Option 2: Cancel Booking
To cancel a booking, the booking id of the booking to be cancelled and the date of cancellation are first entered. The days between the cancellation date and the tour departure date is computed to determine the penalty rate. The booking detail and the penalty are then displayed. This option should display an appropriate message to indicate whether the cancellation is successful.
A sample interaction for option 2 is shown here: see image.
Option 3: Add Seats to Booking
For this option, the booking id of the booking and the number of seats to be added are first entered. The details of the booking before and after the add seats operation is performed are displayed. The cost of each added seats and a discount for existing seats, if applicable, are also displayed. If there is any error, an appropriate error message is displayed. Otherwise, the details of the booking before and after performing the operation are displayed.
A sample interaction for option 3 is shown here: see image.
Option 4: Remove Seats from Booking
In this option, the booking id of the booking, the number of seats to be removed and the date of the request to remove seats are first entered. The details of the booking before and after the operation is performed are displayed. The penalty amount, the refund amount and a top up for each remaining seats, if applicable, are also displayed. If there is any error, an appropriate error message is displayed. Otherwise, the details of the booking before and after performing the operation are displayed.
A sample interaction for option 4 is shown here: see image.
Option 5: Display Booking
This option displays all bookings that have been made. A sample interaction for option S is shown here: see image.