[JAVA-621] Added missing code
* https://www.baeldung.com/java-type-erasure introduction code * https://www.baeldung.com/java-interfaces Electronic interface and Computer class * https://www.baeldung.com/java-abstract-class BoardGame and Checkers classes * https://www.baeldung.com/java-hashcode different ways of implementing hashCode * https://www.baeldung.com/java-inheritance-composition ComputerBuilder and StandardComputerBuilder classes * https://www.baeldung.com/java-equals-hashcode-contracts Renamed method to match article * https://www.baeldung.com/java-static Renamed class to match article * https://www.baeldung.com/java-nested-classes Renamed class to match article
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.baeldung.abstractclasses.overview;
|
||||
|
||||
public abstract class BoardGame {
|
||||
//... field declarations, constructors
|
||||
|
||||
public abstract void play();
|
||||
|
||||
//... concrete methods
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.baeldung.abstractclasses.overview;
|
||||
|
||||
public class Checkers extends BoardGame {
|
||||
@Override
|
||||
public void play() {
|
||||
//... implementation
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.baeldung.interfaces;
|
||||
|
||||
public class Computer implements Electronic {
|
||||
|
||||
@Override
|
||||
public int getElectricityUse() {
|
||||
return 1000;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.baeldung.interfaces;
|
||||
|
||||
public interface Electronic {
|
||||
// Constant variable
|
||||
String LED = "LED";
|
||||
|
||||
// Abstract method
|
||||
int getElectricityUse();
|
||||
|
||||
// Static method
|
||||
static boolean isEnergyEfficient(String electtronicType) {
|
||||
if (electtronicType.equals(LED)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Default method
|
||||
default void printDescription() {
|
||||
System.out.println("Electronic Description");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user