Implement a class Car with the following properties. A car has a certain fuel efficiency (measured in miles/gallon or liters/km - pick one) and a certain amount of fuel in the gas tank. The efficiency is specified in the constructor, and the initial fuel level is 0. Supply a method drive that simulates driving the car for a certain distance, reducing the amount of gasoline in the fuel tank. Also supply methods getGasInTank, returning the current amount of gasoline in the fuel tank, and addGas, to add gasoline to the fuel tank. Sample usage:
Car myHybrid = new Car(50); //
50 miles per gallon
myHybrid.addGas(20); //
Tank 20 gallons
myHybrid.drive(100); //
Drive 100 miles
double gasLeft = myHybrid.getGasInTank(); // Get gas remaining in tank You may assume that the drive method is never called with a distance that consumes more than the available gas. Supply a CarTester class that tests all methods.

Complete the following files:

Car.java

/** A car can drive and consume fuel. */ public class Car { private double gas; private double efficiency; /** Constructs a car with a given fuel efficiency. @param anEfficiency the fuel efficiency of the car */ public Car(double anEfficiency) { . . . } /** Adds gas to the tank. @param amount the amount of fuel to add */ public void addGas(double amount) { . . . } /** Drives a certain amount, consuming gas. @param distance the distance driven */ public void drive(double distance) { . . . } /** Gets the amount of gas left in the tank. @return the amount of gas */ public double getGasInTank() { . . . } }

CarTester.java

/** This program tests the Car class. */ public class CarTester { public static void main(String[] args) { Car myHybrid = new Car(50); // 50 miles per gallon myHybrid.addGas(20); myHybrid.drive(100); // consumes 2 gallons double gasLeft = myHybrid.getGasInTank(); // TODO: Print actual and expected gas level } }

CarTester2.java