Question: Complete the Car class shown below. A Car has a fuel tank level, and a miles-per-gallon value. Assume that all cars have 12-gallon gas tanks.
Complete the Car class shown below. A Car has a fuel tank level, and a miles-per-gallon value. Assume that all cars have 12-gallon gas tanks. public class Car { // declare your constants and instance variables here // postcondition: all instance variables are initialized public Car(double mpgValue, double gallons) { } // postcondition: the fuel level is increased by the amount given by the parameter public void addFuel(double gallons) { } // postcondition: the fuel tank level is decreased by the amount of gas // that it would take this Car to drive the number of miles given by the parameter // The fuel level cannot be negative. public void drive(double miles) { } // other methods not shown }
Must be done in Java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
