Skip to content

Commit 7016d66

Browse files
committed
Feat: fix
1 parent b786150 commit 7016d66

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/EcommerceSystem.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.util.Map;
55
import java.util.UUID;
66

7-
87
public class EcommerceSystem {
98
private Map<String, Product> products;
109
private Map<String, Order> orders;
@@ -18,7 +17,7 @@ public void addProduct(String productId, String name) {
1817
products.put(productId, new Product(productId, name));
1918
}
2019

21-
public String placeOrder(String productId, int quantity) throws ProductNotFoundException{
20+
public String placeOrder(String productId, int quantity) throws ProductNotFoundException {
2221
Product product = products.get(productId);
2322
if (product == null) {
2423
throw new ProductNotFoundException("Product with Id 1 Not found ");
@@ -28,12 +27,10 @@ public String placeOrder(String productId, int quantity) throws ProductNotFound
2827
return orderId;
2928
}
3029

31-
public void cancelOrder(String orderId) throws
32-
OrderNotFoundException{
30+
public void cancelOrder(String orderId) throws OrderNotFoundException {
3331
Order order = orders.get(orderId);
3432
try {
35-
if (order == null ) throw new
36-
OrderNotFoundException("No Such order exists");
33+
if (order == null) throw new OrderNotFoundException("No Such order exists");
3734
} catch (OrderNotFoundException e) {
3835
System.out.println(" order does not exist");
3936
}
@@ -42,7 +39,7 @@ public void cancelOrder(String orderId) throws
4239

4340
public String checkOrderStatus(String orderId) throws OrderNotFoundException {
4441
Order order = orders.get(orderId);
45-
if(order == null) throw new OrderNotFoundException("order with ID 1 not found");
42+
if (order == null) throw new OrderNotFoundException("order with ID 1 not found");
4643
return "Order ID: "
4744
+ orderId
4845
+ ", Product: "

lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55

66
package com.codedifferently.lesson14.ecommerce;
77

8-
class OrderNotFoundException extends RuntimeException{
9-
10-
public OrderNotFoundException(String message) {
11-
super(message);
12-
}
13-
}
14-
15-
8+
class OrderNotFoundException extends RuntimeException {
169

10+
public OrderNotFoundException(String message) {
11+
super(message);
12+
}
13+
}

lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
package com.codedifferently.lesson14.ecommerce;
77

8-
class ProductNotFoundException extends Exception{
9-
public ProductNotFoundException( String message) {
10-
super(message);
11-
}
8+
class ProductNotFoundException extends Exception {
9+
public ProductNotFoundException(String message) {
10+
super(message);
11+
}
1212
}

0 commit comments

Comments
 (0)