moving code from java-core to java-core-lang (#6084)

This commit is contained in:
kyleandari
2019-01-05 15:56:01 -05:00
committed by maibin
parent 2d8ea6d287
commit cd4be8ce9e
12 changed files with 0 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,14 @@
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

@@ -0,0 +1,17 @@
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

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

View File

@@ -0,0 +1,14 @@
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

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,20 @@
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

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

View File

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