Question
Define a class with name Schedule for a rental reservation schedule for a vehicle with a maximum of one year ahead with following members (c++)
Define a class with name Schedule for a rental reservation schedule for a vehicle with a maximum of one year ahead with following members (c++)
1. a private attribute with name vehicle of type pointer to Vehicle this schedule belongs to.
2. a private array of 365 pointers of class Rental with name year used to store a pointer to an object of type Rental for every day a rental exists maximum one year ahead (from today; e.g. on September 25th a rental starting at August 2nd of the following year can be booked; the year can be ignored; rentals are not allowed longing more than 28 days).
3. a private attribute with name next of type pointer to Schedule to set up a list of several to rent vehicles.
4. a public constructor with a single parameter of type pointer to a Vehicle. to initialise the respective attribute. Pointer next and all pointers in array year shall be set to null pointers (no rentals ahead). 5. a public method with name get_vehicle without parameter returning a pointer to the vehicle as function value. 6. a public method with name get_next without parameter returning a pointer to the next schedule as function value.
7. a public method with name set_next with a pointer of type Schedule as parameter assigning the respective attribute.
8. a public method with name isFree with a date of type DayOfYear as first parameter as start day of a planned rental, an integer number of days as second parameter, how long the rental is planned, and a Boolen return value. In the body it shall be checked whether the whole time period will be free (return value true) or not (return value false).
9. a public method with name book with a string for the renting person as first parameter, a date of type DayOfYear as second parameter for the start day of the rental, an integer number of days as third parameters, how long the rental is planned, and a floating point return value. In the body a new object of type Rental on the heap shall be generated and its address being stored in array year for each rental day in a loop (the index into the array for the start day of the rental can be calculated by sending a message get_dayOfYear() to the date object - don't forget to subtract 1). Return value shall be the price for this rental determined by a message get_price sent to the vehicle.
10. a public method with name print with a date of type DayOfYear as parameter without return type, sending a message print to the vehicle and afterwards a message print to the reservation object - if it exists, i.e. it is not a null pointer - for this day in the respective array element (see examples below).
11. a public method with name print without parameter and without return type, writing like in the example below a title "SCHEDULE", then sending a message print to the vehicle and afterwards printing all rentals for the vehicle stored in array year together with their prices- each rental for several days shall be written only once, not again und again for each rental day.
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