From b643a4c488a249f5da91b7765195f404c78c6f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CA1-4U2T1NN=E2=80=9D?= <“a1.austinn19@gmail.com”> Date: Wed, 16 Oct 2024 15:19:05 +0000 Subject: [PATCH 1/5] feat: created chigazograham.json file --- .../main/resources/data/chigazograham.json | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 lesson_09/types/types_app/src/main/resources/data/chigazograham.json diff --git a/lesson_09/types/types_app/src/main/resources/data/chigazograham.json b/lesson_09/types/types_app/src/main/resources/data/chigazograham.json new file mode 100644 index 000000000..292620c54 --- /dev/null +++ b/lesson_09/types/types_app/src/main/resources/data/chigazograham.json @@ -0,0 +1,92 @@ +[ + { + "column1": "ms1wuglcnp", + "column2": "true", + "column3": "6463003749233522688", + "column4": "2.7921879E38", + "column5": "8.442422875678673E307", + "column6": "4743", + "column7": "1270272283" + }, + { + "column1": "7awo0gh", + "column2": "false", + "column3": "7752118028902647808", + "column4": "2.6698281E38", + "column5": "5.605056226818231E307", + "column6": "23516", + "column7": "1704066280" + }, + { + "column1": "cserf78x02", + "column2": "false", + "column3": "2540472457630355968", + "column4": "1.5396288E38", + "column5": "1.50417665803363E308", + "column6": "14580", + "column7": "2114160244" + }, + { + "column1": "zgqnjh5", + "column2": "false", + "column3": "953741867660372224", + "column4": "2.2381432E38", + "column5": "2.493477176095576E307", + "column6": "26539", + "column7": "996751379" + }, + { + "column1": "s5iqo80h3c", + "column2": "false", + "column3": "5714943984670955520", + "column4": "1.932927E38", + "column5": "1.705202914715676E308", + "column6": "7442", + "column7": "1112427416" + }, + { + "column1": "wcuo0zxejh", + "column2": "false", + "column3": "2704740152448495104", + "column4": "1.0179288E38", + "column5": "1.393686380125556E308", + "column6": "32762", + "column7": "1881329776" + }, + { + "column1": "cnq9kjd6hiu", + "column2": "true", + "column3": "6206221245541992448", + "column4": "1.3631897E38", + "column5": "1.2956738103127734E308", + "column6": "30578", + "column7": "1147532001" + }, + { + "column1": "8z0bnd", + "column2": "false", + "column3": "4562348053081931776", + "column4": "1.4620677E38", + "column5": "2.044622864892074E307", + "column6": "17197", + "column7": "1094615070" + }, + { + "column1": "0vl9htqrw", + "column2": "false", + "column3": "6077936030977995776", + "column4": "1.7550462E38", + "column5": "4.752956293100593E307", + "column6": "12867", + "column7": "724629435" + }, + { + "column1": "6ur49", + "column2": "true", + "column3": "1339556241029906688", + "column4": "1.944709E38", + "column5": "9.16514287771922E307", + "column6": "20363", + "column7": "562533284" + } +] \ No newline at end of file From 68ccb5fae54e5e7c969f4a4ace4c2947e82813e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CA1-4U2T1NN=E2=80=9D?= <“a1.austinn19@gmail.com”> Date: Wed, 16 Oct 2024 19:01:53 +0000 Subject: [PATCH 2/5] fix: deleted lesson_09 content from main; --- .../main/resources/data/chigazograham.json | 92 ------------------- 1 file changed, 92 deletions(-) delete mode 100644 lesson_09/types/types_app/src/main/resources/data/chigazograham.json diff --git a/lesson_09/types/types_app/src/main/resources/data/chigazograham.json b/lesson_09/types/types_app/src/main/resources/data/chigazograham.json deleted file mode 100644 index 292620c54..000000000 --- a/lesson_09/types/types_app/src/main/resources/data/chigazograham.json +++ /dev/null @@ -1,92 +0,0 @@ -[ - { - "column1": "ms1wuglcnp", - "column2": "true", - "column3": "6463003749233522688", - "column4": "2.7921879E38", - "column5": "8.442422875678673E307", - "column6": "4743", - "column7": "1270272283" - }, - { - "column1": "7awo0gh", - "column2": "false", - "column3": "7752118028902647808", - "column4": "2.6698281E38", - "column5": "5.605056226818231E307", - "column6": "23516", - "column7": "1704066280" - }, - { - "column1": "cserf78x02", - "column2": "false", - "column3": "2540472457630355968", - "column4": "1.5396288E38", - "column5": "1.50417665803363E308", - "column6": "14580", - "column7": "2114160244" - }, - { - "column1": "zgqnjh5", - "column2": "false", - "column3": "953741867660372224", - "column4": "2.2381432E38", - "column5": "2.493477176095576E307", - "column6": "26539", - "column7": "996751379" - }, - { - "column1": "s5iqo80h3c", - "column2": "false", - "column3": "5714943984670955520", - "column4": "1.932927E38", - "column5": "1.705202914715676E308", - "column6": "7442", - "column7": "1112427416" - }, - { - "column1": "wcuo0zxejh", - "column2": "false", - "column3": "2704740152448495104", - "column4": "1.0179288E38", - "column5": "1.393686380125556E308", - "column6": "32762", - "column7": "1881329776" - }, - { - "column1": "cnq9kjd6hiu", - "column2": "true", - "column3": "6206221245541992448", - "column4": "1.3631897E38", - "column5": "1.2956738103127734E308", - "column6": "30578", - "column7": "1147532001" - }, - { - "column1": "8z0bnd", - "column2": "false", - "column3": "4562348053081931776", - "column4": "1.4620677E38", - "column5": "2.044622864892074E307", - "column6": "17197", - "column7": "1094615070" - }, - { - "column1": "0vl9htqrw", - "column2": "false", - "column3": "6077936030977995776", - "column4": "1.7550462E38", - "column5": "4.752956293100593E307", - "column6": "12867", - "column7": "724629435" - }, - { - "column1": "6ur49", - "column2": "true", - "column3": "1339556241029906688", - "column4": "1.944709E38", - "column5": "9.16514287771922E307", - "column6": "20363", - "column7": "562533284" - } -] \ No newline at end of file From a10a3e4a56e26fad8f150d96853d8d6324c5286b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CA1-4U2T1NN=E2=80=9D?= <“a1.austinn19@gmail.com”> Date: Mon, 28 Oct 2024 16:36:17 +0000 Subject: [PATCH 3/5] feat: created custom exception for the OrderNotFoundException and ProductNotFoundException; added new ProductNotFoundException for placeOrder if product is null; added new OrderNotFoundException for checkOrderStatus if order is null or cancled; --- .../lesson14/ecommerce/EcommerceSystem.java | 10 ++++++++-- .../lesson14/ecommerce/OrderNotFoundException.java | 6 +++++- .../lesson14/ecommerce/ProductNotFoundException.java | 6 +++++- 3 files changed, 18 insertions(+), 4 deletions(-) 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 77cf26937..cf8d973c3 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 @@ -17,10 +17,13 @@ public void addProduct(String productId, String name) { products.put(productId, new Product(productId, name)); } - public String placeOrder(String productId, int quantity) { + public String placeOrder(String productId, int quantity) throws ProductNotFoundException { Product product = products.get(productId); String orderId = UUID.randomUUID().toString(); orders.put(orderId, new Order(orderId, product, quantity)); + if (product == null) { + throw new ProductNotFoundException("Product with ID " + productId + " not found"); + } return orderId; } @@ -28,8 +31,11 @@ public void cancelOrder(String orderId) { orders.remove(orderId); } - public String checkOrderStatus(String orderId) { + public String checkOrderStatus(String orderId) throws OrderNotFoundException { Order order = orders.get(orderId); + if (order == null) { + throw new OrderNotFoundException("Order with ID " + orderId + " not found"); + } return "Order ID: " + orderId + ", Product: " diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java index 0104e0ab8..50607ed33 100644 --- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java +++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java @@ -5,4 +5,8 @@ package com.codedifferently.lesson14.ecommerce; -class OrderNotFoundException {} +class OrderNotFoundException extends Exception { + public OrderNotFoundException(String message) { + super(message); + } +} diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java index 25aa814eb..196ac84ac 100644 --- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java +++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java @@ -5,4 +5,8 @@ package com.codedifferently.lesson14.ecommerce; -class ProductNotFoundException {} +class ProductNotFoundException extends Exception { + public ProductNotFoundException(String message) { + super(message); + } +} From 786a5e956ecceab9855d059818f6f6b0c5eb476e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CA1-4U2T1NN=E2=80=9D?= <“a1.austinn19@gmail.com”> Date: Mon, 28 Oct 2024 16:44:53 +0000 Subject: [PATCH 4/5] feat: added comments explaining my added code; --- .../codedifferently/lesson14/ecommerce/EcommerceSystem.java | 4 ++++ .../lesson14/ecommerce/OrderNotFoundException.java | 2 +- .../lesson14/ecommerce/ProductNotFoundException.java | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) 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 cf8d973c3..704713dad 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 @@ -21,9 +21,11 @@ public String placeOrder(String productId, int quantity) throws ProductNotFoundE Product product = products.get(productId); String orderId = UUID.randomUUID().toString(); orders.put(orderId, new Order(orderId, product, quantity)); + //Asks if product is null and to throw the exception message 'Product with ID {orderId} not found' if it is. if (product == null) { throw new ProductNotFoundException("Product with ID " + productId + " not found"); } + // return orderId; } @@ -33,9 +35,11 @@ public void cancelOrder(String orderId) { public String checkOrderStatus(String orderId) throws OrderNotFoundException { Order order = orders.get(orderId); + //Asks if order is null and to throw the exception message 'Order with ID {orderId} not found' if it is. if (order == null) { throw new OrderNotFoundException("Order with ID " + orderId + " not found"); } + // return "Order ID: " + orderId + ", Product: " diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java index 50607ed33..805aba539 100644 --- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java +++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java @@ -4,7 +4,7 @@ */ package com.codedifferently.lesson14.ecommerce; - +//Custom Exception with the name OrderNotFoundException set to display a string message of your choosing class OrderNotFoundException extends Exception { public OrderNotFoundException(String message) { super(message); diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java index 196ac84ac..aa97039f4 100644 --- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java +++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java @@ -4,7 +4,7 @@ */ package com.codedifferently.lesson14.ecommerce; - +//Custom Exception with the name ProductNotFoundException set to display a string message of your choosing class ProductNotFoundException extends Exception { public ProductNotFoundException(String message) { super(message); From 341eef0c2fc5105716ca4311b6fd81e30a9611a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CA1-4U2T1NN=E2=80=9D?= <“a1.austinn19@gmail.com”> Date: Mon, 28 Oct 2024 16:47:31 +0000 Subject: [PATCH 5/5] fix: ran ./gradlew :exceptions_app:spotlessApply to correct Java formatting; --- .../codedifferently/lesson14/ecommerce/EcommerceSystem.java | 6 ++++-- .../lesson14/ecommerce/OrderNotFoundException.java | 4 +++- .../lesson14/ecommerce/ProductNotFoundException.java | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) 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 704713dad..f08934f2e 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 @@ -21,7 +21,8 @@ public String placeOrder(String productId, int quantity) throws ProductNotFoundE Product product = products.get(productId); String orderId = UUID.randomUUID().toString(); orders.put(orderId, new Order(orderId, product, quantity)); - //Asks if product is null and to throw the exception message 'Product with ID {orderId} not found' if it is. + // Asks if product is null and to throw the exception message 'Product with ID {orderId} not + // found' if it is. if (product == null) { throw new ProductNotFoundException("Product with ID " + productId + " not found"); } @@ -35,7 +36,8 @@ public void cancelOrder(String orderId) { public String checkOrderStatus(String orderId) throws OrderNotFoundException { Order order = orders.get(orderId); - //Asks if order is null and to throw the exception message 'Order with ID {orderId} not found' if it is. + // Asks if order is null and to throw the exception message 'Order with ID {orderId} not found' + // if it is. if (order == null) { throw new OrderNotFoundException("Order with ID " + orderId + " not found"); } diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java index 805aba539..c6021d297 100644 --- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java +++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/OrderNotFoundException.java @@ -4,7 +4,9 @@ */ package com.codedifferently.lesson14.ecommerce; -//Custom Exception with the name OrderNotFoundException set to display a string message of your choosing + +// Custom Exception with the name OrderNotFoundException set to display a string message of your +// choosing class OrderNotFoundException extends Exception { public OrderNotFoundException(String message) { super(message); diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java index aa97039f4..dcea1f3d7 100644 --- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java +++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/ecommerce/ProductNotFoundException.java @@ -4,7 +4,9 @@ */ package com.codedifferently.lesson14.ecommerce; -//Custom Exception with the name ProductNotFoundException set to display a string message of your choosing + +// Custom Exception with the name ProductNotFoundException set to display a string message of your +// choosing class ProductNotFoundException extends Exception { public ProductNotFoundException(String message) { super(message);