Hi guys,
I am going over an old exam paper and need some help with a few of the questions. Below is the scenario given.
Define a class Booking that represents one booking for a performance at a venue. This class has four member variables:
• show, a string that holds the name of the show or performance
• nrTickets, an integer value that indicates the number of tickets booked
• seats, a string that holds seats booked (either “standing” or the seat numbers, e.g. “A6-A10”)
• customer, a string containing the name of the person who made the booking
In addition, the class should have the following member functions:
• A default constructor that initializes show, seats and customer respectively to an empty string.
• nrTickets should be initialized to 0.
• An overloaded constructor that accepts a new booking and sets show, seats, customer and nrTickets to specified values.
• A destructor that does not perform any action.
• An overloaded equality operator== to compare two bookings. The ==operator is implemented as a friend function with the following prototype:
bool operator==(const Booking & booking1, const Booking & booking2)
This function returns true if booking1and booking2 has been made for the same show and customer; and false if not.
• An overloaded operator+ for class Booking so that the following are feasible in the main program: a =b + c; where a, b, and c are all Booking objects. The overloaded operator+ should add the values of the nrTickets member variables. It should also concatenate the value of the seats member variable of the second operand to the value of the seats member variable of the first operand. The show and customer member variables should be the same as for the first operand. The overloaded operator+ should return a Booking object. The prototype is as follows:
Booking &operator+ (const Booking & b1, const Booking & b2);
The overloaded operator+ will allow a customer to buy more tickets and book the seats for the tickets under the same name.
• A member function calcFee() to determine the amount charged for the tickets. Use the following prototype:
float calcFee();
• The fee for “standing” tickets is R100.00 per ticket. All other tickets cost R200.00 per ticket.
• An overloaded extraction operator >> (implemented as a friend function) so that it can be used to input values of type Booking.
• An overloaded insertion operator << (implemented as a friend function) that displays all the member variables of a Booking object.
Create the header file Booking.h that contains the Booking class specification.
I am not sure if I am on the right track here.
Booking.h:
1 2 3 4 5 6 7
|
#ifndef BOOKING_H
#define BOOKING_H
string show;
int nrTickets =0;
string seats;
string customer;
#endif
|
Any assistance/advice would be appreciated.
Thanks