- orderItems)
* If the item is a Bagel: "[bagelType] with [spreadType]"
* If the item is a Cookie: "[cookieType] cookie"
* If the item is a Donut: "[donutType] donut"
- * Otherwise: throw new IllegalStateException()
+ * Otherwise: it is a beverage and should not be added to the list!
*
* NOTE: This method show-cases a switch-case pattern matching.
*/
@@ -68,7 +68,7 @@ public List getFoodItemsForOrder()
case Bagel bagel -> foodItems.add(bagel.bagelType() + " bagel with " + bagel.spreadType());
case Cookie cookie -> foodItems.add(cookie.cookieType() + " cookie");
case Donut donut -> foodItems.add(donut.donutType() + " donut");
- default -> throw new IllegalStateException("Unexpected value: " + item);
+ default -> {}
}
}
return foodItems;
diff --git a/coffee-shop-kata/jdk21/pom.xml b/coffee-shop-kata/jdk21/pom.xml
index 367bf4de..594faae8 100644
--- a/coffee-shop-kata/jdk21/pom.xml
+++ b/coffee-shop-kata/jdk21/pom.xml
@@ -55,6 +55,7 @@
org.assertj
assertj-core
3.24.2
+ test
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 938760e8..a3c87d2a 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
@@ -36,7 +36,7 @@ public CoffeeShopOrder(String customerName, List- orderItems)
* If the item is a Bagel: "[bagelType] with [spreadType]"
* If the item is a Cookie: "[cookieType] cookie"
* If the item is a Donut: "[donutType] donut"
- * Otherwise: throw new IllegalStateException()
+ * Otherwise: it is a beverage and should not be added to the list!
*
* NOTE: This method show-cases a switch-case pattern matching.
*
diff --git a/coffee-shop-kata/jdk8/pom.xml b/coffee-shop-kata/jdk8/pom.xml
index 98632dae..fe09420d 100644
--- a/coffee-shop-kata/jdk8/pom.xml
+++ b/coffee-shop-kata/jdk8/pom.xml
@@ -46,6 +46,7 @@
org.assertj
assertj-core
3.24.2
+ test
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 30e03da0..5408994d 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
@@ -40,7 +40,7 @@ public class CoffeeShopOrder
private final String customerName;
private final List- orderItems;
- public CoffeeShopOrder(String customerName, java.util.List
- orderItems)
+ public CoffeeShopOrder(String customerName, List
- orderItems)
{
this.customerName = customerName;
this.orderItems = orderItems;
@@ -52,7 +52,7 @@ public CoffeeShopOrder(String customerName, java.util.List
- orderItems)
* If the item is a Bagel: "[bagelType] with [spreadType]"
* If the item is a Cookie: "[cookieType] cookie"
* If the item is a Donut: "[donutType] donut"
- * Otherwise: throw new IllegalStateException()
+ * Otherwise: it is a beverage and should not be added to the list!
*
* NOTE: This method show-cases a switch-case pattern matching.
*/
@@ -76,10 +76,6 @@ else if (item instanceof Donut)
Donut donut = (Donut) item;
foodItems.add(donut.getDonutType() + " donut");
}
- else
- {
- throw new IllegalStateException();
- }
}
return foodItems;
}