[JAVA-621] core-java-lang-oop-inheritance module

* Creation

* Moved code from https://www.baeldung.com/java-anonymous-classes

* Moved code from www.baeldung.com/java-polymorphism

* Moved code from www.baeldung.com/java-inheritance

* Moved code from www.baeldung.com/java-variable-method-hiding

* Moved code from https://www.baeldung.com/java-type-casting

* Moved code from https://www.baeldung.com/java-super

* Moved code from www.baeldung.com/java-interfaces

* Moved code from www.baeldung.com/java-abstract-class

* Moved code from www.baeldung.com/java-inner-interfaces

* Moved article references to the new README.md
This commit is contained in:
dupirefr
2020-04-04 11:09:04 +02:00
parent ea61137058
commit 21a98198b6
63 changed files with 44 additions and 25 deletions

View File

@@ -4,6 +4,4 @@ This module contains articles about Object-oriented programming (OOP) in Java
### Relevant Articles:
- [Pass-By-Value as a Parameter Passing Mechanism in Java](https://www.baeldung.com/java-pass-by-value-or-pass-by-reference)
- [Guide to the super Java Keyword](https://www.baeldung.com/java-super)
- [Java Interfaces](https://www.baeldung.com/java-interfaces)
- [[<-- Prev]](/core-java-modules/core-java-lang-oop-2)[[More -->]](/core-java-modules/core-java-lang-oop-4)

View File

@@ -1,5 +0,0 @@
package com.baeldung.interfaces;
public interface Box extends HasColor {
int getHeight();
}

View File

@@ -1,14 +0,0 @@
package com.baeldung.interfaces;
public class Employee {
private double salary;
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
}

View File

@@ -1,17 +0,0 @@
package com.baeldung.interfaces;
import java.util.Comparator;
public class EmployeeSalaryComparator implements Comparator<Employee> {
@Override
public int compare(Employee employeeA, Employee employeeB) {
if (employeeA.getSalary() < employeeB.getSalary()) {
return -1;
} else if (employeeA.getSalary() > employeeB.getSalary()) {
return 1;
} else {
return 0;
}
}
}

View File

@@ -1,4 +0,0 @@
package com.baeldung.interfaces;
public interface HasColor {
}

View File

@@ -1,14 +0,0 @@
package com.baeldung.interfaces.multiinheritance;
public class Car implements Fly,Transform {
@Override
public void fly() {
System.out.println("I can Fly!!");
}
@Override
public void transform() {
System.out.println("I can Transform!!");
}
}

View File

@@ -1,6 +0,0 @@
package com.baeldung.interfaces.multiinheritance;
public interface Fly {
void fly();
}

View File

@@ -1,10 +0,0 @@
package com.baeldung.interfaces.multiinheritance;
public interface Transform {
void transform();
default void printSpecs(){
System.out.println("Transform Specification");
}
}

View File

@@ -1,4 +0,0 @@
package com.baeldung.interfaces.multiinheritance;
public abstract class Vehicle implements Transform {
}

View File

@@ -1,9 +0,0 @@
package com.baeldung.interfaces.polymorphysim;
public class Circle implements Shape {
@Override
public String name() {
return "Circle";
}
}

View File

@@ -1,20 +0,0 @@
package com.baeldung.interfaces.polymorphysim;
import java.util.ArrayList;
import java.util.List;
public class MainTestClass {
public static void main(String[] args) {
List<Shape> shapes = new ArrayList<>();
Shape circleShape = new Circle();
Shape squareShape = new Square();
shapes.add(circleShape);
shapes.add(squareShape);
for (Shape shape : shapes) {
System.out.println(shape.name());
}
}
}

View File

@@ -1,6 +0,0 @@
package com.baeldung.interfaces.polymorphysim;
public interface Shape {
String name();
}

View File

@@ -1,9 +0,0 @@
package com.baeldung.interfaces.polymorphysim;
public class Square implements Shape {
@Override
public String name() {
return "Square";
}
}

View File

@@ -1,13 +0,0 @@
package com.baeldung.keyword;
import com.baeldung.keyword.superkeyword.SuperSub;
/**
* Created by Gebruiker on 5/14/2018.
*/
public class KeywordDemo {
public static void main(String[] args) {
SuperSub child = new SuperSub("message from the child class");
}
}

View File

@@ -1,20 +0,0 @@
package com.baeldung.keyword.superkeyword;
/**
* Created by Gebruiker on 5/14/2018.
*/
public class SuperBase {
String message = "super class";
public SuperBase() {
}
public SuperBase(String message) {
this.message = message;
}
public void printMessage() {
System.out.println(message);
}
}

View File

@@ -1,26 +0,0 @@
package com.baeldung.keyword.superkeyword;
/**
* Created by Gebruiker on 5/15/2018.
*/
public class SuperSub extends SuperBase {
String message = "child class";
public SuperSub(String message) {
super(message);
}
public SuperSub() {
super.printMessage();
printMessage();
}
public void getParentMessage() {
System.out.println(super.message);
}
public void printMessage() {
System.out.println(message);
}
}