Define a class called Vehicle that will be used to check the amount of fuel left in
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 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.
Introduction to Management Science A Modeling and Cases Studies Approach with Spreadsheets
ISBN: 978-0078024061
5th edition
Authors: Frederick S. Hillier, Mark S. Hillier