Question: . . . . Define the class Car which has the following private members: brand: e.g. Toyota, Honda etc. model: eg. Camry, Civic, etc. consumption:
. . . . Define the class Car which has the following private members: brand: e.g. Toyota, Honda etc. model: eg. Camry, Civic, etc. consumption: giving the number of liters of petrol the car consumes per kilometer (2 to 18) kilometers: giving the number of kilometers the car has run since its production (10 to 1000) petrolPrice: a decimal number giving the price of one liter of petrol in dirham (20 to 35) age: giving the age of the car in days since its production (100 to 250) and the following public members: a default constructor (without parameters) a parameterized constructor a set() function which sets all the data member values. This function should check the validity of the last 4 data members, setting the value to 0 if not satisfied. a get() function which returns the values of all the data members. a function averageKmsPer Daxo which returns the average number of kilometers a car has traveled per day (kilometers / age) a function averageltsPerPax which returns the daily average petrol consumption of a car in dirham (kilometers * consumption petrolPrice/age) a function print) which prints a car object details in the given format. Implement the member functions of the class Car enforcing the least privileged principle. I Create a project containing the class interface in a header file (sar.b), the class implementation in a carlmp.cpp file and the main program in a car.cpp file. . . The following driver produces the given sample of input/output: int main { string shiestBrand, obiectModeli int obiectConsumption, obiectKilometers, obiectAge
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
