Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ program its a 2 part question i want only the schedule part to be solved ill add the second part as well for extra

C++ program

its a 2 part question

i want only the schedule part to be solved ill add the second part as well for extra info and if u wana solve it aswell that would be awesome

Part 1///////

Teilaufgabe Klasse Schedule/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 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).

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.

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).

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.

Part 2//////////

Teilaufgabe Klasse DayOfYear/Subtask class DayOfYear

Define a class with name DayOfYear to store a date with following members:

two private short unsigned integer attributes dayOfYear and year, whereas for the date the days of a year starting from January 1st (day 1) to December 31st (day 365) shall be stored.

a static constant private array days as class variable storing the number of the days in the year until January 31st, February 28th, March 31st, ... (leap years shall not be regarded). This class variable shall be defined and initialised outside of the class.

Hint: especially helpful will be instead of the numbers of days in a month 31, 28, 31, 30, ... a summed up number of days at the end of each month to store, i.e. 0, 31, 59, 90, 120, ...

an overloaded public (standard) constructor with two default parameters for the day with default value 1 and the year with default value 365 to initialise both attributes.

an overloaded public constructor with three parameters for the day, month and year to initialise the day of the year. To simply calculate the day of the year use class attribute array days, e.g. for March 15th as day 74 (= 31+28+15 = 59+15).

a public method named get_dayOfYear without parameters returning the value of the respective attribute.

a public overloaded member operator ++ to increment a date exactly one day.

Hint: after December 31st the day will be January 1st of the following year.

a public friend overloaded input operator >> inputting a date in ISO format yyyy-mm-dd from a character input stream.

a public friend output operator << outputting a date onto an output stream in ISO format yyyy-mm-dd (see examples below).

Hint: the values for the month and day can be computed in the body from attributes dayOfYear using array days.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

1. Where do these biases come from?

Answered: 1 week ago

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago