Skip to content

Instantly share code, notes, and snippets.

@NitinPraksash9911
Created January 12, 2021 16:49
Show Gist options
  • Save NitinPraksash9911/057e4f04693bbec944e0d73b40292a71 to your computer and use it in GitHub Desktop.
Save NitinPraksash9911/057e4f04693bbec944e0d73b40292a71 to your computer and use it in GitHub Desktop.
public interface Car {
void accelerate();
}
public interface EngineType {
void turnOnEngine();
}
/***********************/
public class MotorCar implements Car, EngineType {
private Engine engine;
public void turnOnEngine() {
//turn on the engine!
engine.on();
}
public void accelerate() {
//move forward!
engine.powerOn(1000);
}
}
/***********************/
public class ElectricCar implements Car {
public void accelerate() {
//this acceleration is crazy!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment