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) {
20
20
public String placeOrder (String productId , int quantity ) throws ProductNotFoundException {
21
21
Product product = products .get (productId );
22
22
if (product == null ) {
23
- throw new ProductNotFoundException ("Product with ID 1 not found" );
23
+ throw new ProductNotFoundException ("Product with ID 34 not found" );
24
24
}
25
25
String orderId = UUID .randomUUID ().toString ();
26
26
orders .put (orderId , new Order (orderId , product , quantity ));
27
27
return orderId ;
28
28
}
29
29
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 ) {
37
31
orders .remove (orderId );
38
32
}
39
33
40
34
public String checkOrderStatus (String orderId ) throws OrderNotFoundException {
41
35
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" );
43
37
return "Order ID: "
44
38
+ orderId
45
39
+ ", Product: "
You can’t perform that action at this time.
0 commit comments