Question: In c++ 1. Write a Car class having three private member variables called tank, speed and model (model is string). Write public functions called pumpGas,

In c++

1. Write a Car class having three private member variables called tank, speed and model (model is string). Write public functions called pumpGas, goFast and display. The function pumpGas gets an integer for the amount of gas that must be pumped. That value needs to be added to tank (no more than 20 gallons). It must return the amount of gas that is purchased ($4 per gallon). The function goFast should increase the speed by 5 each time it is called. Also write the getters and setters for this class.

2. Modify the above class to enforce principle of least privilege by writing const in the header file where needed.

3. Write the constructor to initialize the tank to 5, the speed to 0 and model to new car.

4. Write the main code to test the above class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!