File tree Expand file tree Collapse file tree 1 file changed +3
-9
lines changed
lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce Expand file tree Collapse file tree 1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change @@ -20,26 +20,20 @@ public void addProduct(String productId, String name) {
2020 public String placeOrder (String productId , int quantity ) throws ProductNotFoundException {
2121 Product product = products .get (productId );
2222 if (product == null ) {
23- throw new ProductNotFoundException ("Product with ID 1 not found" );
23+ throw new ProductNotFoundException ("Product with ID 34 not found" );
2424 }
2525 String orderId = UUID .randomUUID ().toString ();
2626 orders .put (orderId , new Order (orderId , product , quantity ));
2727 return orderId ;
2828 }
2929
30- public void cancelOrder (String orderId ) throws OrderNotFoundException {
31- Order order = orders .get (orderId );
32- try {
33- if (order == null ) throw new OrderNotFoundException ("No Such order exists" );
34- } catch (OrderNotFoundException e ) {
35- System .out .println (" order does not exist" );
36- }
30+ public void cancelOrder (String orderId ) {
3731 orders .remove (orderId );
3832 }
3933
4034 public String checkOrderStatus (String orderId ) throws OrderNotFoundException {
4135 Order order = orders .get (orderId );
42- if (order == null ) throw new OrderNotFoundException ("Order with ID 1 not found" );
36+ if (order == null ) throw new OrderNotFoundException ("Order with ID 33 not found" );
4337 return "Order ID: "
4438 + orderId
4539 + ", Product: "
You can’t perform that action at this time.
0 commit comments