From 53e4857ddcc88d099aa7c5fdb5a254114759d55e Mon Sep 17 00:00:00 2001 From: nguzinski Date: Tue, 5 Dec 2023 15:57:48 -0600 Subject: [PATCH] merging test --- app/src/main/java/stock/model/User.java | 8 ++++---- app/src/main/java/stock/view/Gui.java | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/stock/model/User.java b/app/src/main/java/stock/model/User.java index ca9d40b..2b5a124 100644 --- a/app/src/main/java/stock/model/User.java +++ b/app/src/main/java/stock/model/User.java @@ -75,12 +75,12 @@ public void process_event(String event) { this.stocks.replace(stock, this.stocks.get(stock), this.stocks.get(stock) + 1); } } - case "cant_trade": + // case "cant_trade": // cannot transact for the next two turns // timer ticks down when process_end is called - this.flag_can_trade = false; - this.timer_trade_prohib = 2; - break; + // this.flag_can_trade = false; + //this.timer_trade_prohib = 2; + // break; case "favor_repayment": this.capital *= 1.15f; break; diff --git a/app/src/main/java/stock/view/Gui.java b/app/src/main/java/stock/view/Gui.java index 4755103..edd713f 100644 --- a/app/src/main/java/stock/view/Gui.java +++ b/app/src/main/java/stock/view/Gui.java @@ -268,8 +268,8 @@ public void actionPerformed(ActionEvent e) { if((int) spinner.getValue() >= 1) { a = (int)spinner.getValue(); - if (controller.buy(stocktradedString, stocktradedPrice, (int) spinner.getValue())){ - ownListModel.addElement(stocktradedString + " $" + stocktradedPrice + " " + a); + if (controller.buy(stocktradedString, controller.get_stock_price(stocktradedString), (int) spinner.getValue())){ + ownListModel.addElement(stocktradedString + " $" + controller.get_stock_price(stocktradedString) + " " + a); update(); } @@ -284,7 +284,7 @@ public void actionPerformed(ActionEvent e) { @Override public void actionPerformed(ActionEvent e) { if((int) spinner.getValue() > 0) { - if (controller.sell(stocktradedStringsell, stocktradedPricesell, (int) spinner.getValue())) { + if (controller.sell(stocktradedStringsell, controller.get_stock_price((stocktradedStringsell)), (int) spinner.getValue())) { //System.out.println(); update(); //make sure the gui had the correct stocks to be loaded, if not have them reload, dont just remove the elemeents int he list @@ -362,10 +362,10 @@ private void update_owned_list(){ for (int i = 0; i < ownListModel.size(); i++) { - Float userStockPrice = userprices.get(i); + stocktradedStringsell = usernames.get(i); Integer amount = useramount.get(i); if (amount > 0) { - float price = Float.parseFloat(decimalFormat.format(userStockPrice)); + float price = Float.parseFloat(decimalFormat.format(controller.get_stock_price(stocktradedStringsell))); String newStock = (usernames.get(i) + " $" + price + " " + amount); ownListModel.set(i, (newStock)); }else{ @@ -382,15 +382,14 @@ public void valueChanged(ListSelectionEvent e) if(ownedList.isSelectionEmpty()) chosen_stock_sell = ownListModel.get(0); - costLabel.setText("Cost: $0.00"); if (ownedList.getSelectedValue() != null) { chosen_stock_sell = ownedList.getSelectedValue(); }else{ chosen_stock_sell = ownListModel.get(0); } costLabel.setText("Cost: $0.00"); - chosen_stock = ownedList.getSelectedValue(); - stocktradedStringsell = chosen_stock_sell.substring(0,3); + + stocktradedStringsell = marketList.getSelectedValue().substring(0,3); toBeTraded.setText("Selected Stock: " + stocktradedStringsell); //Float no = price; stocktradedPricesell = controller.get_stock_price(stocktradedStringsell); @@ -492,7 +491,8 @@ public void update(){ this.statsPanel.repaint(); spinner.setValue(0); //System.out.println(player.getCapital()); - + stocktradedPrice = controller.get_stock_price(stocktradedString); + stocktradedPricesell = controller.get_stock_price(stocktradedStringsell); //this.totalPortfolio.repaint(); frame.revalidate(); frame.repaint();