Question
C++ | Hi I need help with this. The first question I got it, but the other 3 I dont. 1.) Define a class for
C++ | Hi I need help with this. The first question I got it, but the other 3 I dont.
1.) Define a class for a type called ShowTicket. (This one is done!)
_________________________________________________________________________________________________________
2.) A theatre sells seats for shows and needs a system to keep track of the seats they have sold tickets for. Define a class for a type called ShowTickets.
The class should contain a collection field for the rows, seat numbers, and whether the tickets have been sold or not. Your class only needs to support 10 sold tickets. Assume a ticket you have not referenced before has a sold status of false.
Include the following member functions:
- A function to check if the ticket has been sold with this signature: bool is_sold(string row, string seat);
- A function to update the ticket status to sold with this signature: void sell_seat(string row, string seat);
- A function to print the row, seat number, and sold status delimited by a space with this signature: string print_ticket(string row, string seat);
An example use of your class follows:
int main () { ShowTickets myticket; if(!myticket.is_sold(AA,101)) myticket.sell_seat (AA,101); cout
The output from this sample would be:
AA 101 sold
AA 102 available
File Name
showtickets.h
Note: You do not need to submit any other code including the main method or any print statements. ONLY the ShowTickets class is required. The above example should be used to test your code but deleted or commented out upon submission.
___________________________________________________________________________________________________________________________________
3.) SportTicket Class
A football club needs a system to keep track of the seats they have sold tickets for. Define a class for a type called SportTicket that inherits from the ShowTicket class you defined earlier. You should include the showticket.h file in your code but not upload the file.
The class should add a new boolean field to store if beer has been purchased at that seat. Define a constructor which accepts as arguments the row and seat number and sets the sold status and beer sold fields to false in the constructor initialization section.
The showticket class has the following protected members:
- string row;
- string seat;
Include the following new member functions:
- A function to check if the ticket has been sold with this signature:bool beer_sold();
- A function to update the beer sold status to sold with this signature: void sell_beer();
- override the print_ticket method to add if beer has been sold or not.
An example use of your class follows:
int main () { SportTicket myticket1(AA,101); SportTicket myticket2(AA,102); myticket1.sell_seat(); myticket2.sell_seat(); myticket2.sell_beer(); cout
The output from this sample would be:
AA 101 sold nobeer AA 102 sold beer
File Name
sportticket.h
Note: You do not need to submit any other code including the main method or any print statements. ONLY the SportTicket class is required. The above example should be used to test your code but deleted or commented out upon submission.
___________________________________________________________________________________________________________________________________
4.) You then add a new class called TicketSales. This new class can print either a ShowTicket or a SportsTicket. You should include the header file sportticket.h in your header
Include the following new member functions
- A function to print either a ShowTicket or a SportTicket with this signature:string print_ticket(ShowTicket *myticket);
An example use of your class follows:
int main () { TicketSales ts; ShowTicket myticket1(AA,101); SportTicket myticket2(AA,102); myticket1.sell_seat(); myticket2.sell_seat(); myticket2.sell_beer(); cout
The output from this sample would be:
AA 101 sold
AA 102 sold beer
File Name
ticketsales.h
Note: You do not need to submit any other code including the main method or any print statements. ONLY the class TicketSales is required. The above example should be used to test your code but deleted or commented out upon submission.
ON there X showticket.h X 1 using namespace std; 2 class ShowTicket{ 3 public: 4 string row; 5 string number; 6 bool sold; 7 ShowTicket (string r, string n) { 8 row=r; 9 number=n; 10 sold=false; 11 } 12 bool is_sold() { return sold; 14 } 15 A void sell_seat() { sold = true; } string print_ticket() { 19 string k = row+" "+number+" 20 if(is_sold () ==1) 21 k+="sold"; 22 else 23 k+="available"; 24 return k;| 25 } 26 }; 27 13 16 17 18 NNNNNNNNPP JOUW NO 00 Jouin WNOStep 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