Question
DIY (50%) You have been provided the fully implemented module/class called TourTicket. class TourTicket { char m_name[41]; // passenger name int m_ticketNumber; void copyName(const char*
DIY (50%)
You have been provided the fully implemented module/class called "TourTicket".
class TourTicket { char m_name[41]; // passenger name int m_ticketNumber; void copyName(const char* str); public: TourTicket(); TourTicket& issue(const char* passengerName); std::ostream& display(std::ostream& coutRef = std::cout)const; bool valid()const; };
Read the code of the class and understand how it works. This class does exactly what needs to be done to complete this workshop. However, you can modify it to your need or taste if you like.
Your Task
Code a module/class called TourBus to encapsulate a TourBus carrying passengers for a city tour using a dynamic TourTicket array.
Your TourBus should come in three sizes:
- 4 passenger private tour
- 16 passengers Mini tour bus
- 22 passengers Full-size bus.
Any attempt to develop a TourBus with a size different than the above should result in an invalid unusable TourBus.
Required Functionalities
- A TourBus should be created using the number of passengers it can carry.
- A TourBus should be able to return if it is in a valid state using a query method called validTour();
- A TourBus Should be able to Board Passengers by issuing their tickets when entering the bus. This should be done using a method called board() returning the reference of the TourBus Object. Execution sample if this is a private tour with 4 passengers:
Boarding 4 Passengers: 1/4- Passenger Name: Homer Simspson 2/4- Passenger Name: Marge Simpson 3/4- Passenger Name: Lisa Simpson 4/4- Passenger Name: Bart Simpson
- A method called startTheTour() Should start the tour as follows: This method should check and make sure the bus is in a valid state, then if all the passengers are boarded, it should print their name and ticket number to start the tour. Execution sample:
When The bus is valid and fully boarded:
Starting the tour.... Passenger List: |Row | Passenger Name | Num | +----+------------------------------------------+-----+ | 1 | Homer Simpson | 100 | | 2 | Marge Simpson | 101 | | 3 | Lisa Simpson | 102 | | 4 | Bart Simpson | 103 | +----+------------------------------------------+-----+
When the bus is valid and not fully boarded:
Cannot start the tour, the bus is not fully boarded!
If bus is in an invalid state, no action will be taken.
Tester Program
/*********************************************************************** // OOP244 Workshop 4 p2: tester program // // File main.cpp // Version 1.0 // Date 2022/09/27 // Author Fardad Soleimanloo // Description // // Revision History // ----------------------------------------------------------- // Name Date Reason // ///////////////////////////////////////////////////////////////// ***********************************************************************/ #include
Execution Sample
Enter the following data: 100 10 22 16 4 John Doe Jane Doe Jack Doe Jill Doe ------------------- Please enter number of passengers: 100 Invalid tour bus! Please enter number of passengers: 10 Invalid tour bus! Please enter number of passengers: 22 Cannot start the tour, the bus is not fully boarded! Please enter number of passengers: 16 Cannot start the tour, the bus is not fully boarded! Please enter number of passengers: 4 Boarding 4 Passengers: 1/4- Passenger Name: John Doe 2/4- Passenger Name: Jane Doe 3/4- Passenger Name: Jack Doe 4/4- Passenger Name: Jill Doe Starting the tour.... Passenger List: |Row | Passenger Name | Num | +----+------------------------------------------+-----+ | 1 | John Doe | 100 | | 2 | Jane Doe | 101 | | 3 | Jack Doe | 102 | | 4 | Jill Doe | 103 | +----+------------------------------------------+-----+
Part 2 Submission (DIY)Files to submit:
reflect.txt and:
TourTicket.cpp TourTicket.h TourBus.cpp TourBus.h main.cpp
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started