From 4b159fa22b76053bc929cd7580cf3d75c2383311 Mon Sep 17 00:00:00 2001 From: Oleksii Aleshchenko Date: Thu, 2 Mar 2023 14:41:44 +0200 Subject: [PATCH] update inheritance example --- .../inheritance/ElectricEngine.java | 4 ++++ .../inheritance/FuelEngine.java | 5 +++++ .../inheritance/Main.java | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/encapsulationInheritancePolymorphism/inheritance/FuelEngine.java diff --git a/src/encapsulationInheritancePolymorphism/inheritance/ElectricEngine.java b/src/encapsulationInheritancePolymorphism/inheritance/ElectricEngine.java index 9d48a3e..e0852cd 100644 --- a/src/encapsulationInheritancePolymorphism/inheritance/ElectricEngine.java +++ b/src/encapsulationInheritancePolymorphism/inheritance/ElectricEngine.java @@ -2,4 +2,8 @@ package encapsulationInheritancePolymorphism.inheritance; public class ElectricEngine extends Engine { private String batteryType; + + /*private class Engine { + private int power; + }*/ } diff --git a/src/encapsulationInheritancePolymorphism/inheritance/FuelEngine.java b/src/encapsulationInheritancePolymorphism/inheritance/FuelEngine.java new file mode 100644 index 0000000..482b600 --- /dev/null +++ b/src/encapsulationInheritancePolymorphism/inheritance/FuelEngine.java @@ -0,0 +1,5 @@ +package encapsulationInheritancePolymorphism.inheritance; + +public class FuelEngine extends Engine { + private String fuelType; +} diff --git a/src/encapsulationInheritancePolymorphism/inheritance/Main.java b/src/encapsulationInheritancePolymorphism/inheritance/Main.java index e4ed9d0..6e7e717 100644 --- a/src/encapsulationInheritancePolymorphism/inheritance/Main.java +++ b/src/encapsulationInheritancePolymorphism/inheritance/Main.java @@ -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(); } }