In: Computer Science
JAVA CODING PLEASE
Create a class SportsCar that inherits from the
Car class (CAR CLASS LISTED BELOW THIS QUESTION).
Include the following:
CAR CLASS:
interface Vehicle{ void Start(); void Stop(); void ChangeSpeed(); } abstract class Car implements Vehicle{ private int year; private int speed; private String make; private static int count=0; public Car(int aYear, String aMake) { year = aYear; make = aMake; speed=0; count++; } abstract void sound(); public static int getCount() { return count; } }
class SportsCar extends Car{
private String roof;
private int doors;
public SportsCar(String r,int d,String m) {
super(0,m);
roof=r;
doors=d;
}
public void ChangeSpeed() {
speed+=20;
if(speed>65) {
throw new
IllegalArgumentException("Invalid Speed");
}
}
public void sound() {
System.out.println("broooom");
}
@Override
public void Start() {
}
@Override
public void Stop() {
}
}
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me