Answer:
public class Car {
//Member variables
private int yearModel;
private String make;
private int speed;
//Constructor
public Car(int yearModel, String make, int speed) {
this.yearModel = yearModel;
this.make = make;
this.speed = speed;
}
//Accessor Methods getters and setters
public int getYearModel() {
return yearModel;
}
public void setYearModel(int yearModel) {
this.yearModel = yearModel;
}
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
//Accelerate function
public void accelerate(){
this.speed+=5;
}
// Brake function
public void brake(){
this.speed-=5;
}
}
Explanation: