update solid ex

This commit is contained in:
Loredana
2019-02-10 18:24:45 +02:00
parent a98aedd25b
commit 68ea49996b
23 changed files with 19 additions and 16 deletions
@@ -0,0 +1,8 @@
package com.baeldung.l;
public interface Car {
void turnOnEngine();
void accelerate();
}
@@ -0,0 +1,12 @@
package com.baeldung.l;
public class ElectricCar implements Car {
public void turnOnEngine() {
throw new AssertionError("I don't have an engine!");
}
public void accelerate() {
//this acceleration is crazy!
}
}
@@ -0,0 +1,13 @@
package com.baeldung.l;
public class Engine {
public void on(){
//vroom.
}
public void powerOn(int amount){
//do something
}
}
@@ -0,0 +1,18 @@
package com.baeldung.l;
public class MotorCar implements Car {
private Engine engine;
//Constructors, getters + setters
public void turnOnEngine() {
//turn on the engine!
engine.on();
}
public void accelerate() {
//move forward!
engine.powerOn(1000);
}
}