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 2c89e805..55d36b28 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 @@ -50,9 +50,11 @@ public CoffeeShopOrder(String customerName, List orderItems) /** * Return a list of custom strings for the customer's food items! - * If the item is a Bagel: Print [bagelType] with [spreadType] - * If the item is a Cookie: Print [cookieType] - * If the item is a Donut: Print [donutType] + * The string format for each food item is as follows: + * If the item is a Bagel: "[bagelType] with [spreadType]" + * If the item is a Cookie: "[cookieType]" + * If the item is a Donut: "[donutType]" + * Otherwise: throw new IllegalStateException() *

* NOTE: This method show-cases a switch-case pattern matching. */ @@ -80,7 +82,6 @@ public List getFoodItemsForOrder() * Total: $Total Price *

* NOTE: The method highlights the usage of a record deconstruction pattern - * HINT: Use instanceOf */ public String generateReceipt() { @@ -110,12 +111,12 @@ else if (item instanceof Cookie(CookieType cookieType, boolean warmed)) /** * Return a list of custom strings for the customer's drinks! - * First drink : Hot Americano - * Second drink : Hot Caramel Latte with Almond Milk - * Third drink : Hot Vanilla Macchiato with Whole Milk - * Fourth drink : MATCHA Tea + * First drink: Hot Americano + * Second drink: Hot Caramel Latte with Almond Milk + * Third drink: Hot Vanilla Macchiato with Whole Milk + * Fourth drink: Matcha Tea *

- * NOTE: This method utilizes sealed classes and permit to define coffee drink types + * NOTE: This method utilize sealed classes and permit to define coffee drink types * (e.g., Americano, Latte, Macchiato) are allowed within a hierarchy. * However, Tea is not part of this hierarchy. */ diff --git a/coffee-shop-kata/CoffeeShopDomain.png b/coffee-shop-kata/CoffeeShopDomain.png index 32c52986..0184dbce 100644 Binary files a/coffee-shop-kata/CoffeeShopDomain.png and b/coffee-shop-kata/CoffeeShopDomain.png differ diff --git a/coffee-shop-kata/SETUP.md b/coffee-shop-kata/SETUP.md index 305e0df0..aa375469 100644 --- a/coffee-shop-kata/SETUP.md +++ b/coffee-shop-kata/SETUP.md @@ -11,11 +11,11 @@ 2. Launch the project in the IDE as a maven project. You can find instructions on how to do that [here](https://www.jetbrains.com/idea/guide/tutorials/working-with-maven/importing-a-project/). 3. To verify that the Java 8 module is set up correctly, - run [CoffeeShopTest](/jdk8/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java) in the - old-java-features module - the class should compile and all tests will pass. + run [CoffeeShopTest](jdk8/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java) in the + jdk8 module - the class should compile and all tests will pass. 4. To verify that the Java 21 module is set up correctly, - run [CoffeeShopTest](/jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java) in the - new-java-features module - the class should compile but most tests will fail. + run [CoffeeShopTest](jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java) in the + jdk21 module - the class should compile but most tests will fail. ### Getting started * Follow the [README](README.md) for instructions on how to complete the kata. \ No newline at end of file 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 13b2e6d9..36053ab3 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 @@ -32,17 +32,19 @@ public CoffeeShopOrder(String customerName, List orderItems) /** * Return a list of custom strings for the customer's food items! - * If the item is a Bagel: Print [bagelType] with [spreadType] - * If the item is a Cookie: Print [cookieType] - * If the item is a Donut: Print [donutType] + * The string format for each food item is as follows: + * If the item is a Bagel: "[bagelType] with [spreadType]" + * If the item is a Cookie: "[cookieType]" + * If the item is a Donut: "[donutType]" + * Otherwise: throw new IllegalStateException() *

* NOTE: This method show-cases a switch-case pattern matching. * * @see ... */ public List getFoodItemsForOrder() { - // TODO implement method - // Hint: look at the Java 8 implementation in the old-java-features module, + // TODO: implement method + // Hint: look at the Java 8 implementation in the jdk8 module, // and the link above to see how pattern matching for switch can be utilized here return null; } @@ -60,17 +62,17 @@ public List getFoodItemsForOrder() { */ public String generateReceipt() { // TODO: Implement the receipt generation logic here. - // Hint: look at the Java 8 implementation in the old-java-features module, + // Hint: look at the Java 8 implementation in the jdk8 module, // and the link above to see how record patterns can be utilized here return null; } /** * Return a list of custom strings for the customer's drinks! - * First drink : Hot Americano - * Second drink : Hot Caramel Latte with Almond Milk - * Third drink : Hot Vanilla Macchiato with Whole Milk - * Fourth drink : MATCHA Tea + * First drink: Hot Americano + * Second drink: Hot Caramel Latte with Almond Milk + * Third drink: Hot Vanilla Macchiato with Whole Milk + * Fourth drink: Matcha Tea *

* NOTE: This method utilize sealed classes and permit to define coffee drink types * (e.g., Americano, Latte, Macchiato) are allowed within a hierarchy. @@ -78,7 +80,7 @@ public String generateReceipt() { */ public List getDrinkForOrder() { - // TODO implement method logic here + // TODO: implement method logic here return null; } } 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 898efaf0..37de0cd4 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 @@ -62,7 +62,8 @@ public void setUp() public void getFoodItemsForOrderTest() { // TODO: Complete the method getFoodItemsForOrder() in CoffeeShopOrder to make this pass - List expected = List.of("GLAZED donut", "toasted EVERYTHING bagel with HERB_GARLIC_CREAM_CHEESE"); + List expected = List.of("EVERYTHING bagel with HERB_GARLIC_CREAM_CHEESE", + "CHOCOLATE_CHIP cookie", "GLAZED donut"); assertEquals(expected, coffeeShopOrder.getFoodItemsForOrder()); } 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 34fb636f..e9ba220d 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 @@ -48,9 +48,11 @@ public CoffeeShopOrder(String customerName, java.util.List orderItems) /** * Return a list of custom strings for the customer's food items! - * If the item is a Bagel: Print [bagelType] with [spreadType] - * If the item is a Cookie: Print [cookieType] - * If the item is a Donut: Print [donutType] + * The string format for each food item is as follows: + * If the item is a Bagel: "[bagelType] with [spreadType]" + * If the item is a Cookie: "[cookieType]" + * If the item is a Donut: "[donutType]" + * Otherwise: throw new IllegalStateException() *

* NOTE: This method show-cases a switch-case pattern matching. */ @@ -76,7 +78,7 @@ else if (item instanceof Donut) } else { - throw new IllegalStateException("Unexpected value: " + item); + throw new IllegalStateException(); } } return foodItems; @@ -126,13 +128,13 @@ else if (item instanceof Cookie) /** * Create and print drink order - * First drink : Hot Americano - * Second drink : Hot Caramel Latte with Almond Milk - * Third drink : Hot Vanilla Macchiato with Whole Milk - * Fourth drink : MATCHA Tea + * First drink: Hot Americano + * Second drink: Hot Caramel Latte with Almond Milk + * Third drink: Hot Vanilla Macchiato with Whole Milk + * Fourth drink: Matcha Tea *

* NOTE: Use interface to create four drinks - * Use the toString() to obtain descriptions of the dinks + * Use the toString() to obtain descriptions of the drinks */ public List getDrinkForOrder() {