From 8cc92d0bd494f33e734436fd3cc8018833c8b792 Mon Sep 17 00:00:00 2001
From: AmiyahJo <86239804+AmiyahJo@users.noreply.github.com>
Date: Tue, 24 Sep 2024 15:05:50 -0400
Subject: [PATCH 01/10] Create README.md
Accidentally removed my work the 1st time by merging
---
lesson_00/amiyahjones/README.md | 43 +++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 lesson_00/amiyahjones/README.md
diff --git a/lesson_00/amiyahjones/README.md b/lesson_00/amiyahjones/README.md
new file mode 100644
index 000000000..14fc62d70
--- /dev/null
+++ b/lesson_00/amiyahjones/README.md
@@ -0,0 +1,43 @@
+# Mya.README
+ ```Javascript
+const Mya = class SoftwareEngineer {
+ intern(code, tools) {
+ self.code = Javascript, HTML, CSS, Java;
+ self.tools = React, Docker;
+ }
+};
+
+// Intrested in bringing ideas to life within a web browser.
+// Learning how websites become quick, responsive, and accesssible to everyone.
+```
+
+
+
+### ☴ My work hours
+9AM-5PM
I'm an early bird and often begin the day with a head start of my work. Feel free to reach me by email during this time, and I'll get back to you as soon as I'm able!
+
+### What's the best way to communicate with me? .☘︎ ݁˖
+Private message through google chat works perfectly. Email works too as a follow up or if I happened to miss one of your messages.
+> [!TIP]
+> _In case I don't respond:_ Ping me again on google chat or send me another email!
+
+### I'd be happy to help you with ꒰ ﹍ ꒱
+* Code suggestions
+* Explain or understand a code snippet
+* Photos + design ideas
+
+## Extra ⓘ
+* ✦ procreate artist ↓
+ - I like to combine my art and code together!
+ - In case you find me with my ipad, that's why
+* visual learner
+* Jr Developer HS Intern for 4 years with Code Differently (youth program)
+* No, I don't drink coffee. ~~Hot chocolate is my go to~~
+
+> I'm the type of person that if you ask me a question and I don't know the answer, I'm gonna tell you that I don't know. But I bet you what, I know how to find the answer and I will find the answer.
- Will smith
+
+
+###### // readme inspired by [Kaeti's repo][kaeti-repo] , code snippet inspired by [Thai Brega]
+
+[kaeti-repo]: https://github.com/kaeti/personal-readme
+[Thai brega]: https://github.com/Thaiane/Thaiane
From 50b18619d9de9203384f678c1e0eee84a70510a0 Mon Sep 17 00:00:00 2001
From: AmiyahJo <86239804+AmiyahJo@users.noreply.github.com>
Date: Tue, 24 Sep 2024 15:07:22 -0400
Subject: [PATCH 02/10] Delete lesson_00/amiyahjones/README.md
---
lesson_00/amiyahjones/README.md | 43 ---------------------------------
1 file changed, 43 deletions(-)
delete mode 100644 lesson_00/amiyahjones/README.md
diff --git a/lesson_00/amiyahjones/README.md b/lesson_00/amiyahjones/README.md
deleted file mode 100644
index 14fc62d70..000000000
--- a/lesson_00/amiyahjones/README.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# Mya.README
- ```Javascript
-const Mya = class SoftwareEngineer {
- intern(code, tools) {
- self.code = Javascript, HTML, CSS, Java;
- self.tools = React, Docker;
- }
-};
-
-// Intrested in bringing ideas to life within a web browser.
-// Learning how websites become quick, responsive, and accesssible to everyone.
-```
-
-
-
-### ☴ My work hours
-9AM-5PM
I'm an early bird and often begin the day with a head start of my work. Feel free to reach me by email during this time, and I'll get back to you as soon as I'm able!
-
-### What's the best way to communicate with me? .☘︎ ݁˖
-Private message through google chat works perfectly. Email works too as a follow up or if I happened to miss one of your messages.
-> [!TIP]
-> _In case I don't respond:_ Ping me again on google chat or send me another email!
-
-### I'd be happy to help you with ꒰ ﹍ ꒱
-* Code suggestions
-* Explain or understand a code snippet
-* Photos + design ideas
-
-## Extra ⓘ
-* ✦ procreate artist ↓
- - I like to combine my art and code together!
- - In case you find me with my ipad, that's why
-* visual learner
-* Jr Developer HS Intern for 4 years with Code Differently (youth program)
-* No, I don't drink coffee. ~~Hot chocolate is my go to~~
-
-> I'm the type of person that if you ask me a question and I don't know the answer, I'm gonna tell you that I don't know. But I bet you what, I know how to find the answer and I will find the answer.
- Will smith
-
-
-###### // readme inspired by [Kaeti's repo][kaeti-repo] , code snippet inspired by [Thai Brega]
-
-[kaeti-repo]: https://github.com/kaeti/personal-readme
-[Thai brega]: https://github.com/Thaiane/Thaiane
From dea41341dc479d6ac63c7526381283786f5962f7 Mon Sep 17 00:00:00 2001
From: AmiyahJo
Date: Mon, 28 Oct 2024 13:55:18 +0000
Subject: [PATCH 03/10] feat: adds try-catch blocks with exceptions
chore: comments for reference
---
.../java/com/codedifferently/lesson14/Lesson14.java | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
index eaeb97baf..5f3b964ae 100644
--- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
+++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
@@ -3,6 +3,16 @@
public class Lesson14 {
public static void main(String[] args) {
- System.out.println("Hello World");
+ // System.out.println("Hello World");
+ try {
+ ecommerceSystem.placeOrder("1", 1);
+ } catch (ProductNotFoundException e) {
+ System.out.println("Product not found.");
+ } catch (OrderNotFoundException e){
+ System.out.println("Order not found.");
+ }
}
}
+
+//ProductNotFoundException <- for product does not exist
+//OrderNotFoundException <- for both order does not exist and order cancelled
From e22ce0f11932215ec15bf1410ee4f07bc818934f Mon Sep 17 00:00:00 2001
From: AmiyahJo
Date: Mon, 28 Oct 2024 14:02:00 +0000
Subject: [PATCH 04/10] fix: lesson14.java inlude string for placing an order
and error messages
---
.../main/java/com/codedifferently/lesson14/Lesson14.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
index 5f3b964ae..f9fe3bc21 100644
--- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
+++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
@@ -5,11 +5,11 @@ public class Lesson14 {
public static void main(String[] args) {
// System.out.println("Hello World");
try {
- ecommerceSystem.placeOrder("1", 1);
+ String orderId = ecommerceSystem.placeOrder("1", 1);
} catch (ProductNotFoundException e) {
- System.out.println("Product not found.");
+ System.out.println("Product with ID " + orderId + " not found.");
} catch (OrderNotFoundException e){
- System.out.println("Order not found.");
+ System.out.println("Order with ID " + orderId + " not found.");
}
}
}
From ec2ce623ea27baf720d06f48285829e64d954c7c Mon Sep 17 00:00:00 2001
From: AmiyahJo
Date: Mon, 28 Oct 2024 14:11:41 +0000
Subject: [PATCH 05/10] feat: adds imports fix: moved string orderid in .java
outside of try block
---
.../java/com/codedifferently/lesson14/Lesson14.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
index f9fe3bc21..8906a5a16 100644
--- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
+++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
@@ -1,13 +1,17 @@
package com.codedifferently.lesson14;
+import com.codedifferently.lesson14.ecommerce.EcommerceSystem;
+import com.codedifferently.lesson14.ecommerce.OrderNotFoundException;
+import com.codedifferently.lesson14.ecommerce.ProductNotFoundException;
+
public class Lesson14 {
public static void main(String[] args) {
- // System.out.println("Hello World");
+ String orderId = null;
try {
- String orderId = ecommerceSystem.placeOrder("1", 1);
+ orderId = ecommerceSystem.placeOrder("1", 1);
} catch (ProductNotFoundException e) {
- System.out.println("Product with ID " + orderId + " not found.");
+ System.out.println("Product with ID " + "1" + " not found.");
} catch (OrderNotFoundException e){
System.out.println("Order with ID " + orderId + " not found.");
}
From 8f6142f208a2b89f6bbe3cc529fcf26f387b0817 Mon Sep 17 00:00:00 2001
From: AmiyahJo
Date: Mon, 28 Oct 2024 14:37:27 +0000
Subject: [PATCH 06/10] feat: adds new exceptoons in ecommerance , adds more
code in both exceptions to extend
---
.../codedifferently/lesson14/Lesson14.java | 23 ++++++++++---------
.../lesson14/ecommerce/EcommerceSystem.java | 10 ++++++--
.../ecommerce/OrderNotFoundException.java | 6 ++++-
.../ecommerce/ProductNotFoundException.java | 6 ++++-
4 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
index 8906a5a16..6366a5cfa 100644
--- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
+++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
@@ -1,20 +1,21 @@
package com.codedifferently.lesson14;
-import com.codedifferently.lesson14.ecommerce.EcommerceSystem;
-import com.codedifferently.lesson14.ecommerce.OrderNotFoundException;
-import com.codedifferently.lesson14.ecommerce.ProductNotFoundException;
+// import com.codedifferently.lesson14.ecommerce.EcommerceSystem;
+// import com.codedifferently.lesson14.ecommerce.OrderNotFoundException;
+// import com.codedifferently.lesson14.ecommerce.ProductNotFoundException;
public class Lesson14 {
public static void main(String[] args) {
- String orderId = null;
- try {
- orderId = ecommerceSystem.placeOrder("1", 1);
- } catch (ProductNotFoundException e) {
- System.out.println("Product with ID " + "1" + " not found.");
- } catch (OrderNotFoundException e){
- System.out.println("Order with ID " + orderId + " not found.");
- }
+ System.out.println("Hello world");
+ // String orderId = null;
+ // try {
+ // orderId = ecommerceSystem.placeOrder("1", 1);
+ // } catch (ProductNotFoundException e) {
+ // System.out.println("Product with ID " + "1" + " not found.");
+ // } catch (OrderNotFoundException e){
+ // System.out.println("Order with ID " + orderId + " not found.");
+ // }
}
}
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..377fdf5a0 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,8 +17,11 @@ 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);
+ if (product == null) {
+ throw new ProductNotFoundException("Product with ID " + productId + " not found.");
+ }
String orderId = UUID.randomUUID().toString();
orders.put(orderId, new Order(orderId, product, quantity));
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..135bdcbcf 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..650ab2e9e 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 4afa2555dae40b77bc25c30477b35aaa12511e33 Mon Sep 17 00:00:00 2001
From: AmiyahJo
Date: Mon, 28 Oct 2024 14:41:14 +0000
Subject: [PATCH 07/10] fix: gradlew spotless to fix violations
---
.../codedifferently/lesson14/Lesson14.java | 20 +++++++++----------
.../ecommerce/OrderNotFoundException.java | 6 +++---
.../ecommerce/ProductNotFoundException.java | 6 +++---
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
index 6366a5cfa..de4064efc 100644
--- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
+++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
@@ -8,16 +8,16 @@ public class Lesson14 {
public static void main(String[] args) {
System.out.println("Hello world");
- // String orderId = null;
- // try {
- // orderId = ecommerceSystem.placeOrder("1", 1);
- // } catch (ProductNotFoundException e) {
- // System.out.println("Product with ID " + "1" + " not found.");
- // } catch (OrderNotFoundException e){
- // System.out.println("Order with ID " + orderId + " not found.");
- // }
+ // String orderId = null;
+ // try {
+ // orderId = ecommerceSystem.placeOrder("1", 1);
+ // } catch (ProductNotFoundException e) {
+ // System.out.println("Product with ID " + "1" + " not found.");
+ // } catch (OrderNotFoundException e){
+ // System.out.println("Order with ID " + orderId + " not found.");
+ // }
}
}
-//ProductNotFoundException <- for product does not exist
-//OrderNotFoundException <- for both order does not exist and order cancelled
+// ProductNotFoundException <- for product does not exist
+// OrderNotFoundException <- for both order does not exist and order cancelled
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 135bdcbcf..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
@@ -6,7 +6,7 @@
package com.codedifferently.lesson14.ecommerce;
class OrderNotFoundException extends Exception {
- public OrderNotFoundException(String message) {
- super(message);
- }
+ 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 650ab2e9e..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
@@ -6,7 +6,7 @@
package com.codedifferently.lesson14.ecommerce;
class ProductNotFoundException extends Exception {
- public ProductNotFoundException(String message) {
- super(message);
- }
+ public ProductNotFoundException(String message) {
+ super(message);
+ }
}
From eea8a91ebaa0e6de4301f1edc2d37c4946252c2d Mon Sep 17 00:00:00 2001
From: AmiyahJo
Date: Mon, 28 Oct 2024 14:45:06 +0000
Subject: [PATCH 08/10] fix: sentence fix (remove a period)
---
.../com/codedifferently/lesson14/ecommerce/EcommerceSystem.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 377fdf5a0..b0ebe1151 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,7 +20,7 @@ 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 " + productId + " not found.");
+ throw new ProductNotFoundException("Product with ID " + productId + " not found");
}
String orderId = UUID.randomUUID().toString();
orders.put(orderId, new Order(orderId, product, quantity));
From 2ce96828f6edf708e00cb26685c519b6a54cbe3b Mon Sep 17 00:00:00 2001
From: AmiyahJo
Date: Mon, 28 Oct 2024 14:47:37 +0000
Subject: [PATCH 09/10] chore: remove comments
---
.../com/codedifferently/lesson14/Lesson14.java | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
index de4064efc..da908e41a 100644
--- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
+++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
@@ -1,23 +1,8 @@
package com.codedifferently.lesson14;
-// import com.codedifferently.lesson14.ecommerce.EcommerceSystem;
-// import com.codedifferently.lesson14.ecommerce.OrderNotFoundException;
-// import com.codedifferently.lesson14.ecommerce.ProductNotFoundException;
-
public class Lesson14 {
public static void main(String[] args) {
System.out.println("Hello world");
- // String orderId = null;
- // try {
- // orderId = ecommerceSystem.placeOrder("1", 1);
- // } catch (ProductNotFoundException e) {
- // System.out.println("Product with ID " + "1" + " not found.");
- // } catch (OrderNotFoundException e){
- // System.out.println("Order with ID " + orderId + " not found.");
- // }
}
-}
-
-// ProductNotFoundException <- for product does not exist
-// OrderNotFoundException <- for both order does not exist and order cancelled
+}
\ No newline at end of file
From be4c0298e64fee95e52ec0b383a95d078a6636ca Mon Sep 17 00:00:00 2001
From: AmiyahJo
Date: Mon, 28 Oct 2024 14:50:11 +0000
Subject: [PATCH 10/10] fix: gradlews spotless apply
---
.../src/main/java/com/codedifferently/lesson14/Lesson14.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
index da908e41a..ba43a6647 100644
--- a/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
+++ b/lesson_14/exceptions/exceptions_app/src/main/java/com/codedifferently/lesson14/Lesson14.java
@@ -5,4 +5,4 @@ public class Lesson14 {
public static void main(String[] args) {
System.out.println("Hello world");
}
-}
\ No newline at end of file
+}