Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ARH80 committed Jun 10, 2020
1 parent afea239 commit a309f09
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/main/java/controller/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,14 @@ public String digest(String productId) {

public void addToCart(String productId) {
if (currentAccount.getRole() == Role.CUSTOMER) {
Map<Product,Integer> cart = currentAccount.getCart();
cart.put(getAvailableProductById(productId),1);
currentAccount.setCart(cart);
if (getProductById(productId).getAmount() > 0) {
Map<Product,Integer> cart = currentAccount.getCart();
cart.put(getAvailableProductById(productId),1);
currentAccount.setCart(cart);
getProductById(productId).setAmount(getProductById(productId).getAmount() - 1);
}
else
System.out.println("not available");
}
else
System.out.println("invalid command");
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/view/Menu/GoodMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,13 @@ public void show() {
System.out.println("Compare Menu");
System.out.println("1.back");
String input = scanner.nextLine();
for (String productAttribute : controller.compare(goodId, input)) {
System.out.println(productAttribute);
if (controller.getProductById(input) != null) {
for (String productAttribute : controller.compare(goodId, input)) {
System.out.println(productAttribute);
}
}
else {
System.out.println("invalid id");
}
}

Expand Down

0 comments on commit a309f09

Please sign in to comment.