tkd10_2004
2013-02-02 16:35:36 UTC
// this is to show that tank is my ref var for the GasTank class
public class Car{
//the manufacturer of the car
private String make;
//the model of the car
private String model;
//the miles per gallon
private double mpg;
private double totalMilesDriven;
//the GasTank
private GasTank tank;
private double tripDistance;
/*
* constructor for a default Car object
*/
public Car(){
//default GasTank
tank = new GasTank(15);
make = "Ford";
model = "Fusion";
totalMilesDriven = 0;
mpg = 20;
tripDistance = 500;
this.beginTrip();
}
//this my drive method from the car class
public void drive(){
Random generator = new Random();
//50 to 100 miles
double milesDriven = (generator.nextDouble()*50) + 50;
if(tank.isEmpty()!= true)
{
tank.burnGas();
}
else
{
System.out.println("You gas tank is empty please add more gas to continue");
}
//print details
this.printTripDetails();
}
this is the isEmpty method from the GasTank class
/**
* Check for an empty tank
* @return true if the tank is empty
*/
public boolean isEmpty(double gallonsLeft){
if (gallonsLeft != 0 )
{
return false;
}
else
{
return true;
}
}
ok what i want to do is the isEmpty() to check for something and then return
true or false. then i want the drive() in the Car class to take the return from the isEmpty() and check it in the if statment of the drive(). This is my issue, it keeps telling me that in my drive() the method isEmpty in GasTank cannot be applied to given types; required: double; found: no arguments; reason: actual and formal argument lists differ in length.
i am first year student in programming and dont understand why i am having this erorr. again what i want to do is if the tank.isEmpty is not = to true then run tank.burnGas() else do the system.out.().
please help or point me in the right direction to figure this out thanks in advance.