Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ Project Subtask class DayOfYear : Define a class with name DayOfYear to store a date with following members: two private short unsigned integer attributes

c++ Project

Subtask class DayOfYear:

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

two private short unsigned integer attributes dayOfYearand 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.

Subtask class Vehicle:

Define an abstract class with name Vehicle with following members:

a private constant integer attribute named no for an identification number of the vehicle.

a private C++ string attribute with name model.

a private attribute with name price24h of data type float for the rental price of one day of the vehicle. a public constructor with an integer, a C++ string and a floating point number as parameters to initialise the three private attributes .

a virtual destructor.

two public methods with names get_no and get_modelwithout parameters returning the values of the respective attributes.

a public method with name get_price with an integer parameter for the number of rental days of the vehicle, which gets multiplied by the rental price of one day returned as function value

a public pure virtual method with name print without parameter and without return value.

Subtask class Bike:

Define a class for bicycles with name Bike inheriting public from class Vehicle with following members:apublic constructor with an integer and a C++ string as parameters to initialise the number and the model; the daily rental price shall always be 9,99 EUR

a public virtual method with name print without parameter and without return type writing the number, the model and afterwards "(Bike)" onto the standard character output stream (see example below).

Subtask class EMotorVehicle:

Define an abstract class with name EMotorVehicleinheriting public from class Vehicle with following members:

a public constructor with an integer, a C++ string and a floating point number as parameters to initialise the three attributes.

a public pure virtual method with name is_streetLegalwithout parameter and a Boolean return type.

a public virtual method with name print without parameter or return value writing the number, the model, and if the vehicle is not street legal "(not street legal)" onto the standard character output stream (see example below).

Subtask class EBike:

Define a class with name EBike inheriting public from class EMotorVehicle with following members:

a public constructor with an integer, a C++ string and a floating point number as parameters to initialise the three attributes; the latter parameter shall be a default parameter with default value 29.99 EUR.

a public virtual method with name is_streetLegal without parameter always returning true (only street legal E-bikes are rented).

a public virtual method with name print without parameter and without return type calling the same name method of its direct upper class and afterwards writing "(EBike)" onto the standard character output stream (see example below).

-

Subtask class EScooter:

Define a class with name EScooter inheriting public from class EMotorVehicle with following members:

a private Boolean attribute with name streetLegal whether the E-scooter is street legal.

a public constructor with an integer, a C++ string, a floating point number and a Boolean value as parameters to initialise the four attributes. The last two parameters shall be a default parameters with default values 19.99 EUR and false.

a public virtual method with name is_streetLegal without parameter returning the value of the respective attribute

a public virtual method with name print without parameter and without return type calling the same name method of its direct upper class and afterwards writing "(EScooter)" onto the standard character output stream (see example below).

-

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

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

Intelligent Image Databases Towards Advanced Image Retrieval

Authors: Yihong Gong

1st Edition

1461375037, 978-1461375036

More Books

Students also viewed these Databases questions

Question

What are the stages of project management? Write it in items.

Answered: 1 week ago

Question

why do consumers often fail to seek out higher yields on deposits ?

Answered: 1 week ago

Question

understand the meaning of the terms discipline and grievance

Answered: 1 week ago