|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectCar
public class Car
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 |
---|
public Car(double mpg)
mpg
- the miles per gallon of this carMethod Detail |
---|
public void addGas(double amount)
amount
- the amount of gas to addpublic void drive(double distance)
distance
- the distance to drivepublic double getGasInTank()
public double getMilesDriven()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |