update inheritance example
This commit is contained in:
parent
2880b770f7
commit
4b159fa22b
|
@ -2,4 +2,8 @@ package encapsulationInheritancePolymorphism.inheritance;
|
|||
|
||||
public class ElectricEngine extends Engine {
|
||||
private String batteryType;
|
||||
|
||||
/*private class Engine {
|
||||
private int power;
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package encapsulationInheritancePolymorphism.inheritance;
|
||||
|
||||
public class FuelEngine extends Engine {
|
||||
private String fuelType;
|
||||
}
|
|
@ -2,6 +2,7 @@ package encapsulationInheritancePolymorphism.inheritance;
|
|||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
ElectricEngine electricEngine = new ElectricEngine();
|
||||
ElectricEngine electricEngine = new ElectricEngine(); // створення нового об'єкту (екземпляру) класу ElectricEngine
|
||||
FuelEngine fuelEngine = new FuelEngine();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue