Skip to content

Commit

Permalink
merging test
Browse files Browse the repository at this point in the history
  • Loading branch information
nguzinski committed Dec 5, 2023
1 parent fec5703 commit 53e4857
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions app/src/main/java/stock/model/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/java/stock/view/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
Expand All @@ -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
Expand Down Expand Up @@ -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{
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 53e4857

Please sign in to comment.