diff --git a/pom.xml b/pom.xml index 7b7e35f..c928da0 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ UTF-8 1.8 1.8 + 2.0.21 @@ -34,6 +35,17 @@ assertj-core 3.23.1 + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + test + @@ -86,5 +98,59 @@ + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + test-compile + test-compile + + test-compile + + + + + ${maven.compiler.target} + + + + org.apache.maven.plugins + maven-compiler-plugin + + + default-compile + none + + + default-testCompile + none + + + compile + compile + + compile + + + + testCompile + test-compile + + testCompile + + + + + diff --git a/src/main/java/com/serenitydojo/Hamster.java b/src/main/java/com/serenitydojo/Hamster.java new file mode 100644 index 0000000..83708e0 --- /dev/null +++ b/src/main/java/com/serenitydojo/Hamster.java @@ -0,0 +1,23 @@ +package com.serenitydojo; + +public class Hamster extends Pet { + private String favoriteWheel; + + public Hamster(String name, int age, String favoriteWheel) { + super(name, age); + this.favoriteWheel = favoriteWheel; + } + + public String getFavoriteWheel() { + return favoriteWheel; + } + + public void setFavoriteWheel(String favoriteWheel) { + this.favoriteWheel = favoriteWheel; + } + + @Override + public String play() { + return "runs in " + favoriteWheel; + } +} diff --git a/src/main/java/com/serenitydojo/Pet.java b/src/main/java/com/serenitydojo/Pet.java new file mode 100644 index 0000000..a98234b --- /dev/null +++ b/src/main/java/com/serenitydojo/Pet.java @@ -0,0 +1,31 @@ +package com.serenitydojo; + +public class Pet { + private String name; + private int age; + + public Pet(String name, int age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String play() { + return "plays"; + } +} diff --git a/src/main/java/com/serenitydojo/model/Feeder.java b/src/main/java/com/serenitydojo/model/Feeder.java index d6e8f1a..d0a8dae 100644 --- a/src/main/java/com/serenitydojo/model/Feeder.java +++ b/src/main/java/com/serenitydojo/model/Feeder.java @@ -1,14 +1,14 @@ package com.serenitydojo.model; public class Feeder { - public String feeds(String animal, boolean isPremium) { + public FoodType feeds(String animal, boolean isPremium) { if (animal.equals("Cat")) { - return (isPremium) ? "Salmon" : "Tuna"; + return (isPremium) ? FoodType.SALMON: FoodType.TUNA; } else if (animal.equals("Dog")) { - return "Dog Food"; + return FoodType.DOG_FOOD; } - return "Cabbage"; + return FoodType.CABBAGE; } } diff --git a/src/main/java/com/serenitydojo/model/FoodType.java b/src/main/java/com/serenitydojo/model/FoodType.java new file mode 100644 index 0000000..c1e4501 --- /dev/null +++ b/src/main/java/com/serenitydojo/model/FoodType.java @@ -0,0 +1,5 @@ +package com.serenitydojo.model; + +public enum FoodType { + TUNA, CABBAGE, LETTUCE, SALMON, DOG_FOOD, DELUXE_DOG_FOOD, UNKNOWN +} diff --git a/src/test/java/com/serenitydojo/WhenFeedingTheAnimals.java b/src/test/java/com/serenitydojo/WhenFeedingTheAnimals.java index 561d46a..b5ed7a7 100644 --- a/src/test/java/com/serenitydojo/WhenFeedingTheAnimals.java +++ b/src/test/java/com/serenitydojo/WhenFeedingTheAnimals.java @@ -1,6 +1,7 @@ package com.serenitydojo; import com.serenitydojo.model.Feeder; +import com.serenitydojo.model.FoodType; import org.junit.Assert; import org.junit.Test; @@ -10,36 +11,36 @@ public class WhenFeedingTheAnimals { public void shouldFeedCatsTuna() { Feeder feeder = new Feeder(); - String food = feeder.feeds("Cat", false); + FoodType food = feeder.feeds("Cat", false); - Assert.assertEquals("Tuna", food); + Assert.assertEquals(FoodType.TUNA, food); } @Test public void shouldFeedHamstersCabbage() { Feeder feeder = new Feeder(); - String food = feeder.feeds("Hamster", false); + FoodType food = feeder.feeds("Hamster", false); - Assert.assertEquals("Cabbage", food); + Assert.assertEquals(FoodType.CABBAGE, food); } @Test public void shouldFeedDogsDogFood() { Feeder feeder = new Feeder(); - String food = feeder.feeds("Dog", false); + FoodType food = feeder.feeds("Dog", false); - Assert.assertEquals("Dog Food", food); + Assert.assertEquals(FoodType.DOG_FOOD, food); } @Test public void shouldFeedPremiumCatsPremiumFood() { Feeder feeder = new Feeder(); - String food = feeder.feeds("Cat", true); + FoodType food = feeder.feeds("Cat", true); - Assert.assertEquals("Salmon", food); + Assert.assertEquals(FoodType.SALMON, food); } }