question archive The Valet Parking accepts two kinds of Vehicles; Car and Motorcycle
Subject:Computer SciencePrice: Bought3
The Valet Parking accepts two kinds of Vehicles; Car and Motorcycle.
The Valet Parking also provides Carwash for the Cars, while they are parked in the parking. It also allows Motorcycles with sidecars to be parked, but this option must be known when the Motorcycle is entering the Parking.
Inherit a Car and a Motorcycle class from the Vehicle class before the final stage of development of this project.
?? Note: that it is possible, (but unlikely) that you may have to go back to milestone 4 and do minor modifications to Vehicle to make these classes work properly.
The Car module
Derive a class called Car from the Vehicle Class in milestone 3.2.
The Car class implementation:
As done before, when implementing the member functions of the class, you are responsible to recognize if a member function can change the state of the class or not. (i.e. if it is a constant function or not or if the arguments of a function are constants or not)
Car Attributes
Only one mandatory attribute is required for a Car:
Carwash flag attribute
In addition to what A Vehicle provides, a Car should be able to store having carwash during parking or not.
Constructor implementation:
a Car can be created using a no-argument constructor that sets the Car (and therefore the Base class Vehicle) to a safe Invalid empty state. Also, a Car like its base class can be created using a license plate and a make and model value. In the latter case, the values are used to set the properties of the Vehicle. If one of the licence plates or make and model are pointing to null or if they are invalid values, the Car is set into an invalid empty state.
Rule of three
A Car should be safely copied and assigned to another car.
Member function implementations:
writeType
Override the pure virtual method writeType to write "C," if the object is in comma-separated values format (isCsv()), or otherwise write Vehicle type: Car" and a NEWLINE.
Read
This function overrides the read method of the Vehicle class.
If the Car is set to Comma Separated mode it will read as follows:
If the Car is not set to Comma Separated mode it will read as follows:
It will prompt on the screen: "Car information entry" and prints a newline character.
It will read the Base class.
Then it will prompt: "Carwash while parked? (Y)es/(N)o: "
Afterwards, it will wait for the user to enter a 'Y' or an 'N' (lowercase or uppercase) and based on the user's response it will set the carwash flag to true or false respectively.
If the user responds with anything thing, other than a single character 'y' or 'n' it will keep printing:
"Invalid response, only (Y)es or (N)o are acceptable, retry: "
and waits for the user to try again.
In the end, the istream object is returned.
Write
This function overrides the write method of the Vehicle class.
If the Car is in an invalid empty state, this function will write the following message using the ostream object and returns the ostream object.
"Invalid Car Object"
When the Car is not in an invalid empty state:
At the end, the ostream object is returned.
The Motorcycle module:
Derive a class called Motorcycle from the Vehicle Class in milestone 3.2.
The Motorcycle class implementation:
As done before, when implementing the member functions of the class, you are responsible to recognize if a member function can change the state of the class or not. (i.e. if it is a constant function or not or if the arguments of a function are constants or not)
Motorcycle attributes
Has Sidecar flag attribute
In addition to what A Vehicle provides, a Motorcycle should be able to store if it has a sidecar attached or not.
Constructor implementation:
a Motorcycle can be created using a no-argument constructor that sets the Motorcycle ( and therefore the Base class Vehicle) to a safe Invalid empty state. Also, a Motorcycle like its base class can be created using a license plate and a make and model value. In the latter case, the values are used to set the properties of the Vehicle. If one of the licence plates or make and model are pointing to null or invalid values, the Motorcycle is set into an invalid empty state.
Rule of three
A Motorcycle should be safely copied and assigned to another Motorcycle.
Member function implementations:
writeType
Override the pure virtual method writeType to write "M," if the object is in comma-separated values format (isCsv()), or otherwise write "Vehicle type: Motorcycle" and a NEWLINE.
Read
This function overrides the read method of the Vehicle class.
If the Motorcycle is set to Comma Separated mode it will read as follows:
If the Motorcycle is not set to Comma Separated mode it will read as follows:
It will prompt on the screen: "Motorcycle information entry" and prints a newline character.
It will read the Base class.
Then it will prompt: "Does the Motorcycle have a sidecar? (Y)es/(N)o: "
Afterwards, it will wait for the user to enter a 'Y' or an 'N' (lowercase or upper case) and based on the user's response it will set the Has Sidecar flag to true or false respectively.
If the user responds with anything thing, other than a single character 'y' or 'n' it will keep printing:
"Invalid response, only (Y)es or (N)o are acceptable, retry: "
and waits for the user to try again.
In the end, the istream object is returned.
Write
This function overrides the write method of the Vehicle class.
If the Motorcycle is in an invalid empty state, this function will write the following message using the ostream object and returns the ostream object.
"Invalid Motorcycle Object"
When the Car Motorcycle is not in an invalid empty state:
In the end, the ostream object is returned.