/**
* @(#)Car.java
*
*Chp.3 3.5
* @author Alec Ziff
* @version 1.00 2011/9/23
*/
public class Car {
{
public Car(double fuelEffciency) //all values are in miles per gallon
{
efficiency= fuelEfficiency;
}
public void addGas(double gas)
{
double newFuel= fuel + gas;
fuel= newFuel;
}
public double drive( double distance)
(
double fuelLevel = fuel - (distance/efficiency);
fuel= fuelLevel;
return fuel;
)
public double getGasInTank()
{
return fuel;
}
private double fuel;
private double efficiency;
}
}
TigerTeck 0 Light Poster
NormR1 563 Posting Sage Team Colleague
TigerTeck 0 Light Poster
NormR1 563 Posting Sage Team Colleague
TigerTeck 0 Light Poster
TigerTeck 0 Light Poster
NormR1 563 Posting Sage Team Colleague
NormR1 563 Posting Sage Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.