Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Car extends CarTester
- {
- private double milesDriven;
- private double gasTank;
- private double getGasInTank;
- private double getMilesDriven;
- /**
- Constructs a car with a given fuel efficiency.
- @param anEfficiency the fuel efficiency of the car
- */
- public Car(double anEfficiency)
- {
- }
- /** Adds gas to the teank.
- @param amount the amount of fuel to add
- */
- public void addGas(double amount)
- {
- gasTank = amount + amount + amount;
- }
- /**
- Drives a certain amount, consuming gas.
- @param distance the distance driven
- */
- public void drive(double distance)
- {
- milesDriven = distance + milesDriven;
- }
- /**
- Gets the amount of gas left in the tank.
- @return the amount of gas
- */
- public double getGasInTank()
- {
- getGasInTank = gasTank - (milesDriven/50);
- return getGasInTank;
- }
- /**
- Gets the total miles driven by this car.
- @return the miles driven
- */
- public double getMilesDriven()
- {
- return milesDriven;
- }
- }
Add Comment
Please, Sign In to add comment