Here's my updated code:
package car1;
public class Main {
public static void main(String[] args) {
class HondaCivic implements car1 {
int speed = 0;
int rpm = 0;
int gear = 1;
public void speedUp(int Increment) {
speed = speed + Increment;}
public void applyBrakes(int Decrement) {
speed = speed - Decrement;}
public void changeRpm(int NewValue) {
rpm = NewValue;}
public void changeGear(int NewValue) {
gear = NewValue;}
public void printStates() {
System.out.println("speed:"+speed+" rpm:"+rpm+" gear:"+gear);}
}
class CarDemo{
public void main(String[] args) {
// Two different Cars
HondaCivic car1 = new HondaCivic();
HondaCivic car2 = new HondaCivic();
// Methods for cars
car1.speedUp(30);
car1.changeGear(3);
car1.changeRpm(3000);
car1.applyBrakes(15);
car1.printStates();
car2.speedUp(30);
car2.changeGear(3);
car2.changeRpm(2000);
car2.applyBrakes(15);
car2.speedUp(5);
car2.changeGear(1);
car2.printStates();
}
} } }
The application will not display the output. I have no idea what to do. Any advice?