diff --git a/src/encapsulationInheritancePolymorphism/polymorphism/ElectricEngine.java b/src/encapsulationInheritancePolymorphism/polymorphism/ElectricEngine.java index 17341fd..85520e0 100644 --- a/src/encapsulationInheritancePolymorphism/polymorphism/ElectricEngine.java +++ b/src/encapsulationInheritancePolymorphism/polymorphism/ElectricEngine.java @@ -3,6 +3,7 @@ package encapsulationInheritancePolymorphism.polymorphism; public class ElectricEngine extends Engine { private String batteryType; + @Override public int getPower() { return 20; } diff --git a/src/encapsulationInheritancePolymorphism/polymorphism/FuelEngine.java b/src/encapsulationInheritancePolymorphism/polymorphism/FuelEngine.java index e31177e..151870d 100644 --- a/src/encapsulationInheritancePolymorphism/polymorphism/FuelEngine.java +++ b/src/encapsulationInheritancePolymorphism/polymorphism/FuelEngine.java @@ -3,6 +3,7 @@ package encapsulationInheritancePolymorphism.polymorphism; public class FuelEngine extends Engine { private String fuelType; + @Override public int getPower() { return 50; } diff --git a/src/encapsulationInheritancePolymorphism/polymorphism/Main.java b/src/encapsulationInheritancePolymorphism/polymorphism/Main.java index a9ec705..6be81c0 100644 --- a/src/encapsulationInheritancePolymorphism/polymorphism/Main.java +++ b/src/encapsulationInheritancePolymorphism/polymorphism/Main.java @@ -22,5 +22,17 @@ public class Main { /*for (int i = 0; i < engines.length; i++) { System.out.println(engines[i].getPower()); }*/ + +// + + int a = 1; + int b = 1; + int c = a + b; + System.out.println(c); + + + String sA = "1"; + String sB = "1"; + String sC = sA + sB; + System.out.println(sC); } } diff --git a/src/encapsulationInheritancePolymorphism/polymorphism/overload/MyClassForOverloadExample.java b/src/encapsulationInheritancePolymorphism/polymorphism/overload/MyClassForOverloadExample.java new file mode 100644 index 0000000..7eeb4b7 --- /dev/null +++ b/src/encapsulationInheritancePolymorphism/polymorphism/overload/MyClassForOverloadExample.java @@ -0,0 +1,17 @@ +package encapsulationInheritancePolymorphism.polymorphism.overload; + +public class MyClassForOverloadExample { + void myMethod(int a) { + System.out.println("Integer: " + a); + } + + void myMethod(double a) { + System.out.println("Double: " + a); + } + + public static void main(String[] args) { + MyClassForOverloadExample overload = new MyClassForOverloadExample(); + overload.myMethod(1); + overload.myMethod(0.1); + } +}