diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/EcommerceSystem.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/EcommerceSystem.java index 76a28c01..b994a032 100644 --- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/EcommerceSystem.java +++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/EcommerceSystem.java @@ -20,26 +20,20 @@ public void addProduct(String productId, String name) { public String placeOrder(String productId, int quantity) throws ProductNotFoundException { Product product = products.get(productId); if (product == null) { - throw new ProductNotFoundException("Product with ID 1 not found"); + throw new ProductNotFoundException("Product with ID 34 not found"); } String orderId = UUID.randomUUID().toString(); orders.put(orderId, new Order(orderId, product, quantity)); return orderId; } - public void cancelOrder(String orderId) throws OrderNotFoundException { - Order order = orders.get(orderId); - try { - if (order == null) throw new OrderNotFoundException("No Such order exists"); - } catch (OrderNotFoundException e) { - System.out.println(" order does not exist"); - } + public void cancelOrder(String orderId) { orders.remove(orderId); } public String checkOrderStatus(String orderId) throws OrderNotFoundException { Order order = orders.get(orderId); - if (order == null) throw new OrderNotFoundException("Order with ID 1 not found"); + if (order == null) throw new OrderNotFoundException("Order with ID 33 not found"); return "Order ID: " + orderId + ", Product: "