From ec4538609d246821184b013b47c3bae17d32561a Mon Sep 17 00:00:00 2001 From: Aqsa Malik Date: Wed, 20 Sep 2023 15:07:08 -0400 Subject: [PATCH] fix readme file and and ignore order for getDrinksForOrder() Signed-off-by: Aqsa Malik --- .../codekatas/coffeeshopkata/CoffeeShopOrder.java | 2 +- .../codekata/coffeeshopkata/CoffeeShopTest.java | 4 +++- coffee-shop-kata/README.md | 15 ++++++++------- coffee-shop-kata/SETUP.md | 4 +++- .../codekatas/coffeeshopkata/CoffeeShopOrder.java | 2 +- .../codekatas/coffeeshopkata/CoffeeShopTest.java | 6 ++++-- .../codekatas/coffeeshopkata/CoffeeShopOrder.java | 2 +- .../codekatas/coffeeshopkata/CoffeeShopTest.java | 4 +++- 8 files changed, 24 insertions(+), 15 deletions(-) diff --git a/coffee-shop-kata-solutions/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java b/coffee-shop-kata-solutions/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java index 427a730..91169cc 100644 --- a/coffee-shop-kata-solutions/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java +++ b/coffee-shop-kata-solutions/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java @@ -122,7 +122,7 @@ public List getFoodItemsForOrder() * (e.g., Americano, Latte, Macchiato) are allowed within a hierarchy. * However, Tea is not part of this hierarchy. */ - public List getDrinkForOrder() + public List getDrinksForOrder() { List drinkItems = new ArrayList<>(); CoffeeDrink coffeeDrink1 = new Americano(DrinkTemperature.HOT); diff --git a/coffee-shop-kata-solutions/src/test/java/bnymellon/codekata/coffeeshopkata/CoffeeShopTest.java b/coffee-shop-kata-solutions/src/test/java/bnymellon/codekata/coffeeshopkata/CoffeeShopTest.java index 919324c..9fb47ba 100644 --- a/coffee-shop-kata-solutions/src/test/java/bnymellon/codekata/coffeeshopkata/CoffeeShopTest.java +++ b/coffee-shop-kata-solutions/src/test/java/bnymellon/codekata/coffeeshopkata/CoffeeShopTest.java @@ -107,6 +107,8 @@ public void getDrinkItems() { List expected = List.of("HOT Americano", "HOT CARAMEL Latte with ALMOND_MILK", "HOT VANILLA Macchiato with WHOLE_MILK", "MATCHA Tea"); - assertEquals(expected, coffeeShopOrder.getDrinkForOrder()); + List actual = coffeeShopOrder.getDrinksForOrder(); + Collections.sort(actual); + assertEquals(expected, actual); } } diff --git a/coffee-shop-kata/README.md b/coffee-shop-kata/README.md index 0bc4dfe..8b477a4 100644 --- a/coffee-shop-kata/README.md +++ b/coffee-shop-kata/README.md @@ -21,6 +21,11 @@ classes that are shared by all the exercises. These are ![Diagram](CoffeeShopDomain.png) ## Overview ## +The following Java concepts will be useful in completing the kata: +* [Records](https://openjdk.org/jeps/395) +* [Record patterns](https://openjdk.org/jeps/440) +* [Pattern matching for switch](https://openjdk.org/jeps/441) +* [Sealed classes](https://openjdk.org/jeps/409) This kata involves refactoring existing code and implementing missing code! All the code you need to complete is in the [`jdk21`](./jdk21) module, with the corresponding solutions in [`coffee-shop-kata-solutions`](../coffee-shop-kata-solutions). The @@ -28,11 +33,7 @@ purpose of the [`jdk8`](./jdk8) module is to show you the Java 8 way of solving problems; there are no TODOs in this module. For technical setup, follow the instructions in [`SETUP.md`](./SETUP.md)! ## Getting started ## -The following Java concepts will be useful in completing the kata: -* [Records](https://openjdk.org/jeps/395) -* [Record patterns](https://openjdk.org/jeps/440) -* [Pattern matching for switch](https://openjdk.org/jeps/441) -* [Sealed classes](https://openjdk.org/jeps/409) -There are failing tests in [CoffeeShopTest](jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java). -Make all the test cases pass by following the TODOs! \ No newline at end of file +1. Run the Tests in [CoffeeShopTest](jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java) +2. Fix the Code Using "TODO" and "HINT" Comments +3. Repeat step 1 and 2 until all tests pass \ No newline at end of file diff --git a/coffee-shop-kata/SETUP.md b/coffee-shop-kata/SETUP.md index 8501d2e..717a599 100644 --- a/coffee-shop-kata/SETUP.md +++ b/coffee-shop-kata/SETUP.md @@ -1,7 +1,9 @@ ## Setting up the project ### Requirements -* [JDK 20](https://jdk.java.net/20/) installed on your computer +* [JDK 20](https://jdk.java.net/20/) installed on your computer + + Note: The latest version of IntelliJ only supports Java 20 * [Maven 3.6.1+](https://maven.apache.org/download.cgi) installed on your computer * [IntelliJ IDEA 2023.1+](https://www.jetbrains.com/idea/download/?section=windows) or similar IDE for Java diff --git a/coffee-shop-kata/jdk21/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java b/coffee-shop-kata/jdk21/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java index 1a7457c..685aa0b 100644 --- a/coffee-shop-kata/jdk21/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java +++ b/coffee-shop-kata/jdk21/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java @@ -78,7 +78,7 @@ public List getFoodItemsForOrder() { * (e.g., Americano, Latte, Macchiato) are allowed within a hierarchy. * However, Tea is not part of this hierarchy. */ - public List getDrinkForOrder() + public List getDrinksForOrder() { // TODO: implement method logic here return Collections.emptyList(); diff --git a/coffee-shop-kata/jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java b/coffee-shop-kata/jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java index e22dc85..780d3e5 100644 --- a/coffee-shop-kata/jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java +++ b/coffee-shop-kata/jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java @@ -113,9 +113,11 @@ public void testSealedClasses() @Test public void getDrinkItems() { - // TODO: Complete the method getDrinkForOrder() in CoffeeShopOrder to make this pass + // TODO: Complete the method getDrinksForOrder() in CoffeeShopOrder to make this pass List expected = List.of("HOT Americano", "HOT CARAMEL Latte with ALMOND_MILK", "HOT VANILLA Macchiato with WHOLE_MILK", "MATCHA Tea"); - assertEquals(expected, coffeeShopOrder.getDrinkForOrder()); + List actual = coffeeShopOrder.getDrinksForOrder(); + Collections.sort(actual); + assertEquals(expected, actual); } } \ No newline at end of file diff --git a/coffee-shop-kata/jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java b/coffee-shop-kata/jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java index e643081..89b772a 100644 --- a/coffee-shop-kata/jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java +++ b/coffee-shop-kata/jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java @@ -135,7 +135,7 @@ else if (item instanceof Donut) * NOTE: Use interface to create four drinks * Use the toString() to obtain descriptions of the drinks */ - public List getDrinkForOrder() + public List getDrinksForOrder() { List drinkItems = new ArrayList<>(); CoffeeDrink coffeeDrink1 = new Americano(DrinkTemperature.HOT); diff --git a/coffee-shop-kata/jdk8/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java b/coffee-shop-kata/jdk8/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java index 8d907ac..5c13c71 100644 --- a/coffee-shop-kata/jdk8/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java +++ b/coffee-shop-kata/jdk8/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java @@ -100,6 +100,8 @@ public void getDrinkItems() expected.add("HOT CARAMEL Latte with ALMOND_MILK"); expected.add("HOT VANILLA Macchiato with WHOLE_MILK"); expected.add("MATCHA Tea"); - assertEquals(expected, coffeeShopOrder.getDrinkForOrder()); + List actual = coffeeShopOrder.getDrinksForOrder(); + Collections.sort(actual); + assertEquals(expected, actual); } }