Question: Define a class called Vehicle that will be used to check the amount of fuel left in a vehicle after travelling a certain distance. The

Define a class called Vehicle that will be used to check the amount of fuel left in a vehicle after travelling a certain distance. The class should have the instance variable tankSize to store the initial size of the tank and efficiency to store the initial efficiency of the vehicle. Set to zero the variable fuelInTank that is used to store the initial amount of fuel in a tank. Include a mutator method that returns initTankSize, initEfficiency and fuelInTank. Include an accessor method addPetrol() that calculates how much fuel can be filled depending on the fuel existing in the tank and the tank's capacity. Also, include a method driveTo() that returns what distance can be travelled with the available fuel and provided efficiency. Use your class with a test program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

python Define a class called Vehicle class Vehicle Initialize the instance variables def initself ta... View full answer

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 Programming Questions!