Question: Program in C++ Subtask class Rental Define a class for a rental with name Rental with following members: a private constant integer attribute with name

Program in C++

Subtask class Rental

Define a class for a rental with name Rental with following members:

  • a private constant integer attribute with name no storing a unique reservation number for the rental.
  • a private attribute with name from of above type DayOfYear storing the starting day of a rental.
  • a private integer attribute with name days storing the number of rental days.
  • a private C++ string attribute with name customer storing the renting person.
  • a private static integer class variable with name last_no to generate a sequence of reservation numbers, which gets incremented each time a new object of this class is generated by the constructor and therefore can be used to automatically take care that all reservations/rentals get a unique identifying number. This class variable shall be defined and initialised outside of the class.
  • a public constructor with a first string parameter for the renting person, a second parameter of type DayOfYear for the starting day of the rental and an integer default parameter for the number of rental days with a default value 1. Beside the initialisation of the attributes related to the respective parameters the attribute no shall get a new unique sequential number using last_no (starting with rental number 1).
  • a public method with name get_days without parameter returning the value of the respective attribute.
  • two public methods with names get_from and get_until without parameters returning the start and end/return date of the rental of type DayOfYear. (Hint: in the body call/use above defined increment operator ++ of class DayOfYear in a loop days times.)
  • a public method with name print without parameter and without return type writing like in the examples below the start day of the rental, string "to", the end day of the rental, string ", rental no" and the reservation number as well as "for" and the renting person onto the standard character output stream.

Subtask class schedule Define a class with name schedule for a rental reservation schedule for a vehicle with a maximum of one year ahead with following members:

  • A private attribute with name vehicle of type pointer to Vehicle this schedule belongs to.
  • 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)
  • a private attribute with name next of type pointer to Schedule to set up a list of several to rent vehicles.
  • 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).
  • a public method with name get_vehicle without parameter returning a pointer to the vehicle as function value.
  • a public method with name get_next without parameter returning a pointer to the next schedule as function value.
  • a public method with name set_next with a pointer of type schedule as parameter assigning the respective attribute.
  • 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 Boolean 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).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!