update inheritance example

This commit is contained in:
Oleksii Aleshchenko 2023-03-02 14:41:44 +02:00
parent 2880b770f7
commit 4b159fa22b
3 changed files with 11 additions and 1 deletions

View File

@ -2,4 +2,8 @@ package encapsulationInheritancePolymorphism.inheritance;
public class ElectricEngine extends Engine {
private String batteryType;
/*private class Engine {
private int power;
}*/
}

View File

@ -0,0 +1,5 @@
package encapsulationInheritancePolymorphism.inheritance;
public class FuelEngine extends Engine {
private String fuelType;
}

View File

@ -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();
}
}