Organized into packages.
This commit is contained in:
parent
0f8c5f9263
commit
cd581154ac
@ -1,12 +0,0 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public interface Creature {
|
||||
|
||||
String getName();
|
||||
|
||||
Size getSize();
|
||||
|
||||
Movement getMovement();
|
||||
|
||||
Color getColor();
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public class Dragon extends AbstractCreature {
|
||||
|
||||
public Dragon() {
|
||||
super("Dragon", Size.LARGE, Movement.FLYING, Color.RED);
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public class Goblin extends AbstractCreature {
|
||||
|
||||
public Goblin() {
|
||||
super("Goblin", Size.SMALL, Movement.WALKING, Color.GREEN);
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public class Octopus extends AbstractCreature {
|
||||
|
||||
public Octopus() {
|
||||
super("Octopus", Size.NORMAL, Movement.SWIMMING, Color.DARK);
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public class Shark extends AbstractCreature {
|
||||
|
||||
public Shark() {
|
||||
super("Shark", Size.NORMAL, Movement.SWIMMING, Color.LIGHT);
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public class Troll extends AbstractCreature {
|
||||
|
||||
public Troll() {
|
||||
super("Troll", Size.LARGE, Movement.WALKING, Color.DARK);
|
||||
}
|
||||
}
|
@ -1,9 +1,21 @@
|
||||
package com.iluwatar;
|
||||
package com.iluwatar.app;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.iluwatar.creature.Creature;
|
||||
import com.iluwatar.creature.Dragon;
|
||||
import com.iluwatar.creature.Goblin;
|
||||
import com.iluwatar.creature.KillerBee;
|
||||
import com.iluwatar.creature.Octopus;
|
||||
import com.iluwatar.creature.Shark;
|
||||
import com.iluwatar.creature.Troll;
|
||||
import com.iluwatar.property.Color;
|
||||
import com.iluwatar.property.Movement;
|
||||
import com.iluwatar.selector.ColorSelector;
|
||||
import com.iluwatar.selector.MovementSelector;
|
||||
|
||||
public class App {
|
||||
public static void main( String[] args ) {
|
||||
// initialize creatures list
|
@ -1,4 +1,8 @@
|
||||
package com.iluwatar;
|
||||
package com.iluwatar.creature;
|
||||
|
||||
import com.iluwatar.property.Color;
|
||||
import com.iluwatar.property.Movement;
|
||||
import com.iluwatar.property.Size;
|
||||
|
||||
public abstract class AbstractCreature implements Creature {
|
||||
|
@ -0,0 +1,16 @@
|
||||
package com.iluwatar.creature;
|
||||
|
||||
import com.iluwatar.property.Color;
|
||||
import com.iluwatar.property.Movement;
|
||||
import com.iluwatar.property.Size;
|
||||
|
||||
public interface Creature {
|
||||
|
||||
String getName();
|
||||
|
||||
Size getSize();
|
||||
|
||||
Movement getMovement();
|
||||
|
||||
Color getColor();
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.iluwatar.creature;
|
||||
|
||||
import com.iluwatar.property.Color;
|
||||
import com.iluwatar.property.Movement;
|
||||
import com.iluwatar.property.Size;
|
||||
|
||||
public class Dragon extends AbstractCreature {
|
||||
|
||||
public Dragon() {
|
||||
super("Dragon", Size.LARGE, Movement.FLYING, Color.RED);
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.iluwatar.creature;
|
||||
|
||||
import com.iluwatar.property.Color;
|
||||
import com.iluwatar.property.Movement;
|
||||
import com.iluwatar.property.Size;
|
||||
|
||||
public class Goblin extends AbstractCreature {
|
||||
|
||||
public Goblin() {
|
||||
super("Goblin", Size.SMALL, Movement.WALKING, Color.GREEN);
|
||||
}
|
||||
}
|
@ -1,4 +1,8 @@
|
||||
package com.iluwatar;
|
||||
package com.iluwatar.creature;
|
||||
|
||||
import com.iluwatar.property.Color;
|
||||
import com.iluwatar.property.Movement;
|
||||
import com.iluwatar.property.Size;
|
||||
|
||||
public class KillerBee extends AbstractCreature {
|
||||
|
@ -0,0 +1,12 @@
|
||||
package com.iluwatar.creature;
|
||||
|
||||
import com.iluwatar.property.Color;
|
||||
import com.iluwatar.property.Movement;
|
||||
import com.iluwatar.property.Size;
|
||||
|
||||
public class Octopus extends AbstractCreature {
|
||||
|
||||
public Octopus() {
|
||||
super("Octopus", Size.NORMAL, Movement.SWIMMING, Color.DARK);
|
||||
}
|
||||
}
|
12
specification/src/main/java/com/iluwatar/creature/Shark.java
Normal file
12
specification/src/main/java/com/iluwatar/creature/Shark.java
Normal file
@ -0,0 +1,12 @@
|
||||
package com.iluwatar.creature;
|
||||
|
||||
import com.iluwatar.property.Color;
|
||||
import com.iluwatar.property.Movement;
|
||||
import com.iluwatar.property.Size;
|
||||
|
||||
public class Shark extends AbstractCreature {
|
||||
|
||||
public Shark() {
|
||||
super("Shark", Size.NORMAL, Movement.SWIMMING, Color.LIGHT);
|
||||
}
|
||||
}
|
12
specification/src/main/java/com/iluwatar/creature/Troll.java
Normal file
12
specification/src/main/java/com/iluwatar/creature/Troll.java
Normal file
@ -0,0 +1,12 @@
|
||||
package com.iluwatar.creature;
|
||||
|
||||
import com.iluwatar.property.Color;
|
||||
import com.iluwatar.property.Movement;
|
||||
import com.iluwatar.property.Size;
|
||||
|
||||
public class Troll extends AbstractCreature {
|
||||
|
||||
public Troll() {
|
||||
super("Troll", Size.LARGE, Movement.WALKING, Color.DARK);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.iluwatar;
|
||||
package com.iluwatar.property;
|
||||
|
||||
public enum Color {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.iluwatar;
|
||||
package com.iluwatar.property;
|
||||
|
||||
public enum Movement {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.iluwatar;
|
||||
package com.iluwatar.property;
|
||||
|
||||
/**
|
||||
*
|
@ -1,7 +1,10 @@
|
||||
package com.iluwatar;
|
||||
package com.iluwatar.selector;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.iluwatar.creature.Creature;
|
||||
import com.iluwatar.property.Color;
|
||||
|
||||
public class ColorSelector implements Predicate<Creature> {
|
||||
|
||||
private final Color c;
|
@ -1,7 +1,10 @@
|
||||
package com.iluwatar;
|
||||
package com.iluwatar.selector;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.iluwatar.creature.Creature;
|
||||
import com.iluwatar.property.Movement;
|
||||
|
||||
public class MovementSelector implements Predicate<Creature> {
|
||||
|
||||
private final Movement m;
|
@ -1,7 +1,10 @@
|
||||
package com.iluwatar;
|
||||
package com.iluwatar.selector;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.iluwatar.creature.Creature;
|
||||
import com.iluwatar.property.Size;
|
||||
|
||||
public class SizeSelector implements Predicate<Creature> {
|
||||
|
||||
private final Size s;
|
@ -1,7 +1,9 @@
|
||||
package com.iluwatar;
|
||||
package com.iluwatar.app;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.iluwatar.app.App;
|
||||
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
Loading…
x
Reference in New Issue
Block a user