From ceea427198e368388ed98f1f469cc88e608d55f3 Mon Sep 17 00:00:00 2001 From: ASUSCenter Date: Fri, 26 Jun 2020 17:57:00 +0430 Subject: [PATCH] some debug --- src/main/java/controller/BuyLogPage.java | 16 ++++++++++------ src/main/java/controller/CartPage.java | 4 ++++ src/main/java/controller/OffPage.java | 2 +- src/main/java/controller/ProductsPage.java | 2 +- src/main/java/models/Buyer.java | 1 + src/main/java/models/Cart.java | 4 ++-- src/main/resources/fxml/ProductPage.fxml | 2 +- target/classes/controller/BuyLogPage.class | Bin 2650 -> 2701 bytes target/classes/controller/BuyerControl.class | Bin 3103 -> 3160 bytes target/classes/controller/CartPage.class | Bin 3615 -> 3723 bytes target/classes/controller/EditPage.class | Bin 2189 -> 2306 bytes target/classes/controller/LoginRegister.class | Bin 1652 -> 1704 bytes target/classes/controller/SellerControl.class | Bin 2320 -> 2358 bytes target/classes/models/Account$1.class | Bin 691 -> 644 bytes target/classes/models/Product.class | Bin 7154 -> 7236 bytes target/classes/models/Request.class | Bin 5740 -> 5923 bytes target/classes/view/OffsPage.class | Bin 2461 -> 2449 bytes target/classes/view/SellerPage$1.class | Bin 1003 -> 997 bytes target/classes/view/SellerPage$2.class | Bin 1022 -> 1016 bytes target/classes/view/SellerPage$3.class | Bin 1634 -> 1628 bytes target/classes/view/SellerPage$4.class | Bin 1037 -> 1044 bytes target/classes/view/SellerPage$5.class | Bin 1295 -> 1289 bytes .../sellerCommands/ViewOffs.class | Bin 2440 -> 2428 bytes 23 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/controller/BuyLogPage.java b/src/main/java/controller/BuyLogPage.java index 08341a9..fdf642c 100644 --- a/src/main/java/controller/BuyLogPage.java +++ b/src/main/java/controller/BuyLogPage.java @@ -48,12 +48,16 @@ public void handle(MouseEvent e) { } } }; - for (BuyLog buyLog : Main.getAccount().getBuyLogList()) { - Button button = new Button(); - button.setId(Integer.toString(buyLog.getCode())); - button.setText(Integer.toString(buyLog.getCode())); - button.addEventHandler(MouseEvent.MOUSE_CLICKED, eventHandler); - vBox.getChildren().add(button); + try { + for (BuyLog buyLog : Main.getAccount().getBuyLogList()) { + Button button = new Button(); + button.setId(Integer.toString(buyLog.getCode())); + button.setText(Integer.toString(buyLog.getCode())); + button.addEventHandler(MouseEvent.MOUSE_CLICKED, eventHandler); + vBox.getChildren().add(button); + } + }catch (Exception e){ + } scrollPane.setContent(vBox); } diff --git a/src/main/java/controller/CartPage.java b/src/main/java/controller/CartPage.java index f13e63c..f14436e 100644 --- a/src/main/java/controller/CartPage.java +++ b/src/main/java/controller/CartPage.java @@ -80,6 +80,10 @@ public void showProductPage(MouseEvent mouseEvent) throws IOException { public void purchase(MouseEvent mouseEvent) { + try { BuyerControl.purchase(Main.getAccount(), Discount.getDiscountByCode(Integer.parseInt(discountCodeText.getText()))); + }catch (Exception e){ + BuyerControl.purchase(Main.getAccount(), null); + } } } diff --git a/src/main/java/controller/OffPage.java b/src/main/java/controller/OffPage.java index 8b6776a..9925a03 100644 --- a/src/main/java/controller/OffPage.java +++ b/src/main/java/controller/OffPage.java @@ -66,7 +66,7 @@ public void back(MouseEvent mouseEvent) throws IOException { public void showProductPage(MouseEvent mouseEvent) throws IOException { if (chosenProduct != null){ Main.setProduct(chosenProduct); - Main.setScene("productPage"); + Main.setScene("ProductPage"); } } } diff --git a/src/main/java/controller/ProductsPage.java b/src/main/java/controller/ProductsPage.java index fa0b9be..24f60d3 100644 --- a/src/main/java/controller/ProductsPage.java +++ b/src/main/java/controller/ProductsPage.java @@ -63,7 +63,7 @@ public void back(MouseEvent mouseEvent) throws IOException { public void showProductPage(MouseEvent mouseEvent) throws IOException { if (chosenProduct != null){ Main.setProduct(chosenProduct); - Main.setScene("productPage"); + Main.setScene("ProductPage"); } } } diff --git a/src/main/java/models/Buyer.java b/src/main/java/models/Buyer.java index f479191..5566344 100644 --- a/src/main/java/models/Buyer.java +++ b/src/main/java/models/Buyer.java @@ -10,6 +10,7 @@ public Buyer(String username) { super(username); super.setAccountType(AccountType.BUYER); allAccounts.add(this); + cart = new Cart(); } public Cart getCart() { diff --git a/src/main/java/models/Cart.java b/src/main/java/models/Cart.java index 05e6199..a5869fa 100644 --- a/src/main/java/models/Cart.java +++ b/src/main/java/models/Cart.java @@ -20,8 +20,8 @@ public void changeAmountOfProduct(Product product, int change) { public int getTotalPrice() { int total = 0; - for (Product product : amountOfProducts.keySet()) { - total = total + product.getPrice() * amountOfProducts.get(product); + for (Product product : products) { + total = total + product.getPrice() ; } return total; } diff --git a/src/main/resources/fxml/ProductPage.fxml b/src/main/resources/fxml/ProductPage.fxml index bc6d01e..65397ab 100644 --- a/src/main/resources/fxml/ProductPage.fxml +++ b/src/main/resources/fxml/ProductPage.fxml @@ -11,7 +11,7 @@ -