Class Car

java.lang.Object
  extended by Car

public class Car
extends Object

A simulated car that consumes gas as it drives.


Constructor Summary
Car(double mpg)
          Constructs a car with a given fuel efficiency.
 
Method Summary
 void addGas(double amount)
          Adds gas to the tank of this car.
 void drive(double distance)
          Drives this car by a given distance.
 double getGasInTank()
          Gets the current amount of gas in the tank of this car.
 double getMilesDriven()
          Gets the current mileage of this car.
 
Methods inherited from class
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Car

public Car(double mpg)
Constructs a car with a given fuel efficiency.

Parameters:
mpg - the miles per gallon of this car
Method Detail

addGas

public void addGas(double amount)
Adds gas to the tank of this car.

Parameters:
amount - the amount of gas to add

drive

public void drive(double distance)
Drives this car by a given distance.

Parameters:
distance - the distance to drive

getGasInTank

public double getGasInTank()
Gets the current amount of gas in the tank of this car.

Returns:
the current gas level

getMilesDriven

public double getMilesDriven()
Gets the current mileage of this car.

Returns:
the total number of miles driven