Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can you help me please conplete the following classes to give the resoult output shown below. the classes' functions are defined in the table below.

can you help me please conplete the following classes to give the resoult output shown below. the classes' functions are defined in the table below.
main function is complete no need to change. thank you. image text in transcribed
image text in transcribed
image text in transcribed
class Vehicle { protected: float m_hourlyRate; int m_age; // age of vehicle in years float m_vehicleValue; // in RM public: virtual float getRentalCost(int numHours) = @; virtual float getInsuranceCost() = 0; virtual void showVehicleInfo() = 0; bool getLoadingStatus(); // returm true if m_age >5 (loading applied) Vehicle() {} class Lorry : public Vehicle { public: virtual float getRentalCost(int numHours); virtual float getInsuranceCost(); virtual void showVehicleInfo(); Lorry(float hourlyRate, int age, float vehicleval); Lorry() {} friend bool operator==(Lorry v1, Lorry v2); }; class Car : public Vehicle { public: virtual float getRentalCost(int numHours); virtual float getInsuranceCost(); virtual void showVehicleInfo(); Car(float hourlyRate, int age, float vehicleval); Car() {} int main() { Vehicle* ptr = new Lorry(100, 6, 88000); ptr->showVehicleInfo(); cout getRentalCost(); // rent for 8 hours cout getInsuranceCost(); cout showVehicleInfo(); cout getRentalCost(5); // rent for 5 hours cout getInsuranceCost(); Lorry oL1(300, 7,50000); Lorry OL2(380, 8, 50000); cout 5 Insurance cost for lorry = 12000 Vehicle type : car Hourly rental rate - RM50 Vehicle age = 3 Vehicle value = 20000 Rental of car for 5 hours 200 Insurance cost for car - 2000 Lorry oLi and oL2 have unequal age and value Figure 3: Sample execution output of main(). Methods Marks bool Vehicle::getLoading Status(): float Lorry::getRentalCost(int numHours) 2 Lorry(float hourly Rate, int age, float vehicleVal) float Lorry::getInsuranceCost() void Lorry::showVehicleInfo() float Car::getRentalCost(int numHours) Explanantion Return true if the age of vehicle is above 5 else return false. This is used for insurance cost calculation Compute and return the rental charge for Lorry object cost = m_hourlyRate * numHours Constructor for Lorry class used to initialize the member variables based on the input argument Compute and return the insurance charge (cost) for Lorry object cost = (0.2 m_vehicleValue) + load 1000.0 The load value = 1 if vehicle age above 5 years old. Else load=0 See figure 3 for sample output for lorry object Compute and return the rental charge for Car object. A discount of 80% is given. cost = 0.8 * (m_hourlyRate * numHours) Constructor for Car class used to initialize the member variables based on the input argument Compute and return the insurance charge for Car object. Additional RM1000 is charge if vehicle age exceed 5 years. cost = (0.1 * m_vehicleValue) See figure 3 for sample output for Car object Return true if the age and value for both v1 and V2 Lorry objects are the same. Return false otherwise Car(float hourly Rate, int age, float vehicleVal) float Car::getInsuranceCost) void Car::showVehicleInfo() bool operator==(Lorry v1, Lorry v2) Draw UML diagram for all the three class class Vehicle { protected: float m_hourlyRate; int m_age; // age of vehicle in years float m_vehicleValue; // in RM public: virtual float getRentalCost(int numHours) = @; virtual float getInsuranceCost() = 0; virtual void showVehicleInfo() = 0; bool getLoadingStatus(); // returm true if m_age >5 (loading applied) Vehicle() {} class Lorry : public Vehicle { public: virtual float getRentalCost(int numHours); virtual float getInsuranceCost(); virtual void showVehicleInfo(); Lorry(float hourlyRate, int age, float vehicleval); Lorry() {} friend bool operator==(Lorry v1, Lorry v2); }; class Car : public Vehicle { public: virtual float getRentalCost(int numHours); virtual float getInsuranceCost(); virtual void showVehicleInfo(); Car(float hourlyRate, int age, float vehicleval); Car() {} int main() { Vehicle* ptr = new Lorry(100, 6, 88000); ptr->showVehicleInfo(); cout getRentalCost(); // rent for 8 hours cout getInsuranceCost(); cout showVehicleInfo(); cout getRentalCost(5); // rent for 5 hours cout getInsuranceCost(); Lorry oL1(300, 7,50000); Lorry OL2(380, 8, 50000); cout 5 Insurance cost for lorry = 12000 Vehicle type : car Hourly rental rate - RM50 Vehicle age = 3 Vehicle value = 20000 Rental of car for 5 hours 200 Insurance cost for car - 2000 Lorry oLi and oL2 have unequal age and value Figure 3: Sample execution output of main(). Methods Marks bool Vehicle::getLoading Status(): float Lorry::getRentalCost(int numHours) 2 Lorry(float hourly Rate, int age, float vehicleVal) float Lorry::getInsuranceCost() void Lorry::showVehicleInfo() float Car::getRentalCost(int numHours) Explanantion Return true if the age of vehicle is above 5 else return false. This is used for insurance cost calculation Compute and return the rental charge for Lorry object cost = m_hourlyRate * numHours Constructor for Lorry class used to initialize the member variables based on the input argument Compute and return the insurance charge (cost) for Lorry object cost = (0.2 m_vehicleValue) + load 1000.0 The load value = 1 if vehicle age above 5 years old. Else load=0 See figure 3 for sample output for lorry object Compute and return the rental charge for Car object. A discount of 80% is given. cost = 0.8 * (m_hourlyRate * numHours) Constructor for Car class used to initialize the member variables based on the input argument Compute and return the insurance charge for Car object. Additional RM1000 is charge if vehicle age exceed 5 years. cost = (0.1 * m_vehicleValue) See figure 3 for sample output for Car object Return true if the age and value for both v1 and V2 Lorry objects are the same. Return false otherwise Car(float hourly Rate, int age, float vehicleVal) float Car::getInsuranceCost) void Car::showVehicleInfo() bool operator==(Lorry v1, Lorry v2) Draw UML diagram for all the three class

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_2

Step: 3

blur-text-image_3

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

Managing Your Information How To Design And Create A Textual Database On Your Microcomputer

Authors: Tenopir, Carol, Lundeen, Gerald

1st Edition

1555700233, 9781555700232

More Books

Students also viewed these Databases questions

Question

When are entry and exit pseudostates used?

Answered: 1 week ago

Question

Make efficient use of your practice time?

Answered: 1 week ago