From 0deaff1e4b9ba4e77b765cccfab4a1ec675a6dd1 Mon Sep 17 00:00:00 2001 From: redshirt4 Date: Tue, 4 Jul 2017 14:45:57 -0400 Subject: [PATCH] Addressed pull request comments: - Classes as a whole removed, not just method/constructor stubs - Commenting out tests undone per discussion, #683 - Enum 'Plant' re-added to Kindergarten Garden per discussion - .keep added to empty source folders --- .../collatz-conjecture/src/main/java/.keep | 0 .../src/main/java/CollatzCalculator.java | 3 - .../src/test/java/CollatzCalculatorTest.java | 24 +- .../src/main/java/KindergartenGarden.java | 3 - .../src/main/java/Plant.java | 21 ++ .../src/test/java/KindergartenGardenTest.java | 216 +++++++++--------- 6 files changed, 141 insertions(+), 126 deletions(-) create mode 100644 exercises/collatz-conjecture/src/main/java/.keep delete mode 100644 exercises/collatz-conjecture/src/main/java/CollatzCalculator.java delete mode 100644 exercises/kindergarten-garden/src/main/java/KindergartenGarden.java create mode 100644 exercises/kindergarten-garden/src/main/java/Plant.java diff --git a/exercises/collatz-conjecture/src/main/java/.keep b/exercises/collatz-conjecture/src/main/java/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/exercises/collatz-conjecture/src/main/java/CollatzCalculator.java b/exercises/collatz-conjecture/src/main/java/CollatzCalculator.java deleted file mode 100644 index 447166445..000000000 --- a/exercises/collatz-conjecture/src/main/java/CollatzCalculator.java +++ /dev/null @@ -1,3 +0,0 @@ -class CollatzCalculator { - -} diff --git a/exercises/collatz-conjecture/src/test/java/CollatzCalculatorTest.java b/exercises/collatz-conjecture/src/test/java/CollatzCalculatorTest.java index 7e0c61fcd..fe178d8b5 100644 --- a/exercises/collatz-conjecture/src/test/java/CollatzCalculatorTest.java +++ b/exercises/collatz-conjecture/src/test/java/CollatzCalculatorTest.java @@ -23,43 +23,43 @@ public void setUp() { @Test public void testZeroStepsRequiredWhenStartingFrom1() { -// assertEquals(0, collatzCalculator.computeStepCount(1)); + assertEquals(0, collatzCalculator.computeStepCount(1)); } @Ignore("Remove to run test") @Test public void testCorrectNumberOfStepsWhenAllStepsAreDivisions() { -// assertEquals(4, collatzCalculator.computeStepCount(16)); + assertEquals(4, collatzCalculator.computeStepCount(16)); } @Ignore("Remove to run test") @Test public void testCorrectNumberOfStepsWhenBothStepTypesAreNeeded() { -// assertEquals(9, collatzCalculator.computeStepCount(12)); + assertEquals(9, collatzCalculator.computeStepCount(12)); } @Ignore("Remove to run test") @Test public void testAVeryLargeInput() { -// assertEquals(152, collatzCalculator.computeStepCount(1000000)); + assertEquals(152, collatzCalculator.computeStepCount(1000000)); } @Ignore("Remove to run test") @Test public void testZeroIsConsideredInvalidInput() { -// expectedException.expect(IllegalArgumentException.class); -// expectedException.expectMessage("Only natural numbers are allowed"); -// -// collatzCalculator.computeStepCount(0); + expectedException.expect(IllegalArgumentException.class); + expectedException.expectMessage("Only natural numbers are allowed"); + + collatzCalculator.computeStepCount(0); } @Ignore("Remove to run test") @Test public void testNegativeIntegerIsConsideredInvalidInput() { -// expectedException.expect(IllegalArgumentException.class); -// expectedException.expectMessage("Only natural numbers are allowed"); -// -// collatzCalculator.computeStepCount(-15); + expectedException.expect(IllegalArgumentException.class); + expectedException.expectMessage("Only natural numbers are allowed"); + + collatzCalculator.computeStepCount(-15); } } diff --git a/exercises/kindergarten-garden/src/main/java/KindergartenGarden.java b/exercises/kindergarten-garden/src/main/java/KindergartenGarden.java deleted file mode 100644 index 54a2a7455..000000000 --- a/exercises/kindergarten-garden/src/main/java/KindergartenGarden.java +++ /dev/null @@ -1,3 +0,0 @@ -public class KindergartenGarden { - -} \ No newline at end of file diff --git a/exercises/kindergarten-garden/src/main/java/Plant.java b/exercises/kindergarten-garden/src/main/java/Plant.java new file mode 100644 index 000000000..d51541c71 --- /dev/null +++ b/exercises/kindergarten-garden/src/main/java/Plant.java @@ -0,0 +1,21 @@ +public enum Plant { + VIOLETS, + RADISHES, + CLOVER, + GRASS; + + public static Plant getPlant(char plantCode) { + switch (plantCode) { + case 'G': + return GRASS; + case 'C': + return CLOVER; + case 'R': + return RADISHES; + case 'V': + return VIOLETS; + } + + return null; + } +} \ No newline at end of file diff --git a/exercises/kindergarten-garden/src/test/java/KindergartenGardenTest.java b/exercises/kindergarten-garden/src/test/java/KindergartenGardenTest.java index a002b9b64..5957a91f6 100644 --- a/exercises/kindergarten-garden/src/test/java/KindergartenGardenTest.java +++ b/exercises/kindergarten-garden/src/test/java/KindergartenGardenTest.java @@ -10,173 +10,173 @@ public class KindergartenGardenTest { @Test public void singleStudent() { -// String student = "Alice"; -// String plants = "RC\nGG"; -// List expected = Arrays.asList(Plant.RADISHES, Plant.CLOVER, Plant.GRASS, Plant.GRASS); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants).getPlantsOfStudent(student) -// ); + String student = "Alice"; + String plants = "RC\nGG"; + List expected = Arrays.asList(Plant.RADISHES, Plant.CLOVER, Plant.GRASS, Plant.GRASS); + + assertEquals( + expected, + new KindergartenGarden(plants).getPlantsOfStudent(student) + ); } @Ignore("Remove to run test") @Test public void singleStudent2() { -// String student = "Alice"; -// String plants = "VC\nRC"; -// List expected = Arrays.asList(Plant.VIOLETS, Plant.CLOVER, Plant.RADISHES, Plant.CLOVER); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants).getPlantsOfStudent(student) -// ); + String student = "Alice"; + String plants = "VC\nRC"; + List expected = Arrays.asList(Plant.VIOLETS, Plant.CLOVER, Plant.RADISHES, Plant.CLOVER); + + assertEquals( + expected, + new KindergartenGarden(plants).getPlantsOfStudent(student) + ); } @Ignore("Remove to run test") @Test public void twoStudents() { -// String student = "Bob"; -// String plants = "VVCG\nVVRC"; -// List expected = Arrays.asList(Plant.CLOVER, Plant.GRASS, Plant.RADISHES, Plant.CLOVER); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants).getPlantsOfStudent(student) -// ); + String student = "Bob"; + String plants = "VVCG\nVVRC"; + List expected = Arrays.asList(Plant.CLOVER, Plant.GRASS, Plant.RADISHES, Plant.CLOVER); + + assertEquals( + expected, + new KindergartenGarden(plants).getPlantsOfStudent(student) + ); } @Ignore("Remove to run test") @Test public void oneGardenSecondStudent() { -// String student = "Bob"; -// String plants = "VVCCGG\nVVCCGG"; -// List expected = Arrays.asList(Plant.CLOVER, Plant.CLOVER, Plant.CLOVER, Plant.CLOVER); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants).getPlantsOfStudent(student) -// ); + String student = "Bob"; + String plants = "VVCCGG\nVVCCGG"; + List expected = Arrays.asList(Plant.CLOVER, Plant.CLOVER, Plant.CLOVER, Plant.CLOVER); + + assertEquals( + expected, + new KindergartenGarden(plants).getPlantsOfStudent(student) + ); } @Ignore("Remove to run test") @Test public void oneGardenThirdStudent() { -// String student = "Charlie"; -// String plants = "VVCCGG\nVVCCGG"; -// List expected = Arrays.asList(Plant.GRASS, Plant.GRASS, Plant.GRASS, Plant.GRASS); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants).getPlantsOfStudent(student) -// ); + String student = "Charlie"; + String plants = "VVCCGG\nVVCCGG"; + List expected = Arrays.asList(Plant.GRASS, Plant.GRASS, Plant.GRASS, Plant.GRASS); + + assertEquals( + expected, + new KindergartenGarden(plants).getPlantsOfStudent(student) + ); } @Ignore("Remove to run test") @Test public void fullGardenFirstStudent() { -// String student = "Alice"; -// String plants = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV"; -// List expected = Arrays.asList(Plant.VIOLETS, Plant.RADISHES, Plant.VIOLETS, Plant.RADISHES); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants).getPlantsOfStudent(student) -// ); + String student = "Alice"; + String plants = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV"; + List expected = Arrays.asList(Plant.VIOLETS, Plant.RADISHES, Plant.VIOLETS, Plant.RADISHES); + + assertEquals( + expected, + new KindergartenGarden(plants).getPlantsOfStudent(student) + ); } @Ignore("Remove to run test") @Test public void fullGardenSecondStudent() { -// String student = "Bob"; -// String plants = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV"; -// List expected = Arrays.asList(Plant.CLOVER, Plant.GRASS, Plant.CLOVER, Plant.CLOVER); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants).getPlantsOfStudent(student) -// ); + String student = "Bob"; + String plants = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV"; + List expected = Arrays.asList(Plant.CLOVER, Plant.GRASS, Plant.CLOVER, Plant.CLOVER); + + assertEquals( + expected, + new KindergartenGarden(plants).getPlantsOfStudent(student) + ); } @Ignore("Remove to run test") @Test public void fullGardenSecondToLastStudent() { -// String student = "Kincaid"; -// String plants = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV"; -// List expected = Arrays.asList(Plant.GRASS, Plant.CLOVER, Plant.CLOVER, Plant.GRASS); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants).getPlantsOfStudent(student) -// ); + String student = "Kincaid"; + String plants = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV"; + List expected = Arrays.asList(Plant.GRASS, Plant.CLOVER, Plant.CLOVER, Plant.GRASS); + + assertEquals( + expected, + new KindergartenGarden(plants).getPlantsOfStudent(student) + ); } @Ignore("Remove to run test") @Test public void fullGardenLastStudent() { -// String student = "Larry"; -// String plants = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV"; -// List expected = Arrays.asList(Plant.GRASS, Plant.VIOLETS, Plant.CLOVER, Plant.VIOLETS); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants).getPlantsOfStudent(student) -// ); + String student = "Larry"; + String plants = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV"; + List expected = Arrays.asList(Plant.GRASS, Plant.VIOLETS, Plant.CLOVER, Plant.VIOLETS); + + assertEquals( + expected, + new KindergartenGarden(plants).getPlantsOfStudent(student) + ); } @Ignore("Remove to run test") @Test public void customStudentGardenFirstStudentInAlphabeticalOrder() { -// String[] studentArray = {"Samantha", "Patricia", "Xander", "Roger"}; -// String student = "Patricia"; -// String plants = "VCRRGVRG\nRVGCCGCV"; -// List expected = Arrays.asList(Plant.VIOLETS, Plant.CLOVER, Plant.RADISHES, Plant.VIOLETS); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants, studentArray).getPlantsOfStudent(student) -// ); + String[] studentArray = {"Samantha", "Patricia", "Xander", "Roger"}; + String student = "Patricia"; + String plants = "VCRRGVRG\nRVGCCGCV"; + List expected = Arrays.asList(Plant.VIOLETS, Plant.CLOVER, Plant.RADISHES, Plant.VIOLETS); + + assertEquals( + expected, + new KindergartenGarden(plants, studentArray).getPlantsOfStudent(student) + ); } @Ignore("Remove to run test") @Test public void customStudentGardenSecondStudentInAlphabeticalOrder() { -// String[] studentArray = {"Samantha", "Patricia", "Xander", "Roger"}; -// String student = "Roger"; -// String plants = "VCRRGVRG\nRVGCCGCV"; -// List expected = Arrays.asList(Plant.RADISHES, Plant.RADISHES, Plant.GRASS, Plant.CLOVER); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants, studentArray).getPlantsOfStudent(student) -// ); + String[] studentArray = {"Samantha", "Patricia", "Xander", "Roger"}; + String student = "Roger"; + String plants = "VCRRGVRG\nRVGCCGCV"; + List expected = Arrays.asList(Plant.RADISHES, Plant.RADISHES, Plant.GRASS, Plant.CLOVER); + + assertEquals( + expected, + new KindergartenGarden(plants, studentArray).getPlantsOfStudent(student) + ); } @Ignore("Remove to run test") @Test public void customStudentGardenThirdStudentInAlphabeticalOrder() { -// String[] studentArray = {"Samantha", "Patricia", "Xander", "Roger"}; -// String student = "Samantha"; -// String plants = "VCRRGVRG\nRVGCCGCV"; -// List expected = Arrays.asList(Plant.GRASS, Plant.VIOLETS, Plant.CLOVER, Plant.GRASS); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants, studentArray).getPlantsOfStudent(student) -// ); + String[] studentArray = {"Samantha", "Patricia", "Xander", "Roger"}; + String student = "Samantha"; + String plants = "VCRRGVRG\nRVGCCGCV"; + List expected = Arrays.asList(Plant.GRASS, Plant.VIOLETS, Plant.CLOVER, Plant.GRASS); + + assertEquals( + expected, + new KindergartenGarden(plants, studentArray).getPlantsOfStudent(student) + ); } @Ignore("Remove to run test") @Test public void customStudentGardenFourthStudentInAlphabeticalOrder() { -// String[] studentArray = {"Samantha", "Patricia", "Xander", "Roger"}; -// String student = "Xander"; -// String plants = "VCRRGVRG\nRVGCCGCV"; -// List expected = Arrays.asList(Plant.RADISHES, Plant.GRASS, Plant.CLOVER, Plant.VIOLETS); -// -// assertEquals( -// expected, -// new KindergartenGarden(plants, studentArray).getPlantsOfStudent(student) -// ); + String[] studentArray = {"Samantha", "Patricia", "Xander", "Roger"}; + String student = "Xander"; + String plants = "VCRRGVRG\nRVGCCGCV"; + List expected = Arrays.asList(Plant.RADISHES, Plant.GRASS, Plant.CLOVER, Plant.VIOLETS); + + assertEquals( + expected, + new KindergartenGarden(plants, studentArray).getPlantsOfStudent(student) + ); } }