Skip to content

Commit

Permalink
Updated TransactionUI to address the known bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Li committed Mar 1, 2015
1 parent 91b1d9c commit e53a0fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions MerchantRPGCSE2102/src/model/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ public boolean sell(String itemName, Merchant targetMerchant, int amount) throws
return true;
}
else
throw new MerchantNotEnoughCashException();
return false;
}
else
return false;
throw new MerchantNotEnoughCashException();
}

/**
Expand Down
15 changes: 8 additions & 7 deletions MerchantRPGCSE2102/src/view/TransactionUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,12 @@ public static void createSellWindow()
frame.setContentPane(contentPane);
contentPane.setLayout(null);

String[] itemList = new String[MASTER.getPlayer().getInventory().length]; //create a new array of strings with the length of the player's inventory //item that the player chooses from the combobox
String[] itemList = new String[MASTER.getTargetMerchant().getInventory().length]; //create a new array of strings with the length of the player's inventory
for(int i = 0; i < itemList.length; i++) //adds all the item names to the item list
{
itemList[i] = MASTER.getPlayer().getInventory()[i].getItemName();
itemList[i] = itemList[i] + " (x" + MASTER.getPlayer().getInventory()[i].getQuantity() + ")";
itemList[i] = MASTER.getTargetMerchant().getInventory()[i].getItemName();
itemList[i] = itemList[i] + " (x" + MASTER.getPlayer().getInventory()[i].getQuantity() + ")"; //appends the quantity of items that the player has
itemList[i] = itemList[i] + " ($" + MASTER.getTargetMerchant().getInventory()[i].getAdjustedPrice() + ")"; //appends the price of the item
}

JLabel lblYouHave = new JLabel(MASTER.getTargetMerchant().getName() + " has: $" + MASTER.getTargetMerchant().getCurrentCash());
Expand Down Expand Up @@ -289,12 +290,12 @@ public void mouseClicked(MouseEvent e) { //information is consumed w
else
throw new NumberFormatException(); //will throw a NumberFormatException if actionSell returns a false
}
catch(NumberFormatException exception){
System.out.println("Must input a number less than or equal to the total amount of the item that you have");
catch(MerchantNotEnoughCashException mnecexception){
System.out.println("Merchant does not have enough cash");
}
}
catch(MerchantNotEnoughCashException mnecexception){
System.out.println("Merchant does not have enough cash");
catch(NumberFormatException exception){
System.out.println("Must input a number less than or equal to the total amount of the item that you have");
}
}
catch(NotInInventoryException niiexception){
Expand Down

0 comments on commit e53a0fb

Please sign in to comment.