I trying to learn some Java and I've got stuck creating a subclass. I keep getting a There is no default constructor available in... error.
This is the code:
class Car
{
String name;
int speed;
int gear;
int drivetrain;
String direction;
String color;
String fuel;
public Car(String carName, int carSpeed, String carDirection, String carColor, int carDriveTrain, int carGear)
{
name = carName;
speed = carSpeed;
gear = carGear;
drivetrain = carDriveTrain;
direction = carDirection;
color = carColor;
fuel = "Gas";
}
void shiftGears(int newGear){gear = newGear; }
void accelerateSpeed(int acceleration){speed = speed + acceleration; }
void applyBrake(int brakingFactor){ speed = speed - brakingFactor;}
void turnWheel(String newDirection){ direction = newDirection; }
}//end of Car class
class Suv extends Car
{
void applyBrake(int brakingFactor)
{
super.applyBrake(brakingFactor);
speed = speed - brakingFactor;
}
}
The issue comes when I try to create the "Suv" subclass. What am I doing wrong? Thanks!
Suvwhich gets the same parameters asCar.