So I am using the superclass Vehicle and subclass Van. The Van subclass inherits horsepower, weight, and aerodynamics from the superclass. I have also defined a new instance variable in Van called carryweight. When I try to run TestAcceleration.java I get this error:
Here is the code:
VEHICLE SUPERCLASS
public class Vehicle
{
public double horsepower;
public double aerodynamics;
public double weight;
public Vehicle(double hp, double w, double ad)
{
horsepower = hp;
weight = w;
aerodynamics = ad;
}
public double getHorsepower()
{
return horsepower;
}
public double getAerodynamics()
{
return aerodynamics;
}
public double getWeight()
{
return weight;
}
public double acceleration()
{
double calcAccel = (100/horsepower)*aerodynamics*weight/100;
double roundAccel = Math.round(calcAccel * 100.0) / 100.0;
return roundAccel;
}
}
VAN SUBCLASS
public class Van extends Vehicle
{
public double carryweight;
public Van(double hp, double w, double ad, double cw)
{
super(hp, w, ad, cw);
carryweight = cw;
}
public double getCarryweight()
{
return carryweight;
}
public double acceleration()
{
double calcAccel = (100/horsepower)*(aerodynamics/2)*weight/100;
double roundAccel = Math.round(calcAccel * 100.0) / 100.0;
return roundAccel;
}
}
TESTACCELERATION CLASS
public class TestAcceleration
{
public static void main (String[] args)
{
Vehicle car1 = new Van(100, 3500, 0.9, 160.4);
System.out.println(car1.acceleration());
}
}