Skip to content

Chigazo Lesson 14 Ecommerce System #475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
887b8f0
Merge pull request #1 from code-differently/main
A1-4U2T1NN Sep 26, 2024
05ad627
Merge branch 'code-differently:main' into main
A1-4U2T1NN Sep 27, 2024
5715b6a
Merge branch 'code-differently:main' into main
A1-4U2T1NN Sep 30, 2024
6c909b0
Merge branch 'code-differently:main' into main
A1-4U2T1NN Sep 30, 2024
4c1a3f2
Merge branch 'code-differently:main' into main
A1-4U2T1NN Sep 30, 2024
de19403
Merge branch 'code-differently:main' into main
A1-4U2T1NN Sep 30, 2024
56aa83d
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 1, 2024
8529105
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 2, 2024
4f76813
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 3, 2024
48bf962
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 5, 2024
1da88b9
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 7, 2024
3068765
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 9, 2024
712efd6
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 11, 2024
5db7413
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 11, 2024
5096f8e
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 12, 2024
09341aa
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 14, 2024
a8f634e
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 15, 2024
b643a4c
feat: created chigazograham.json file
Oct 16, 2024
cae2152
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 16, 2024
68ccb5f
fix: deleted lesson_09 content from main;
Oct 16, 2024
7d4f86f
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 16, 2024
473eb98
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 17, 2024
1d19106
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 17, 2024
bba5af5
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 18, 2024
a51c852
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 19, 2024
8a39fcc
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 21, 2024
ac98745
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 22, 2024
eade00f
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 23, 2024
bf252ad
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 23, 2024
955b86f
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 25, 2024
b6f63bd
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 28, 2024
a10a3e4
feat: created custom exception for the OrderNotFoundException and Pro…
Oct 28, 2024
786a5e9
feat: added comments explaining my added code;
Oct 28, 2024
341eef0
fix: ran ./gradlew :exceptions_app:spotlessApply to correct Java form…
Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,31 @@ 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));
// Asks if product is null and to throw the exception message 'Product with ID {orderId} not
// found' if it is.
if (product == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Odd to put it here since an empty product would probably lead the Order constructor to blow up. Check your inputs before you do any work in the function.

throw new ProductNotFoundException("Product with ID " + productId + " not found");
}
//
return orderId;
}

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);
// 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: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@

package com.codedifferently.lesson14.ecommerce;

class OrderNotFoundException {}
// 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@

package com.codedifferently.lesson14.ecommerce;

class ProductNotFoundException {}
// 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);
}
}