Skip to content

Commit

Permalink
Updated TransactionUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Li committed Feb 24, 2015
1 parent a4c54d7 commit 346b22a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
4 changes: 1 addition & 3 deletions MerchantRPGCSE2102/src/controller/RPGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ else if (merchantNumber == 3)
}
}


/**
* This method returns the player's inventory list
*
Expand All @@ -127,7 +126,6 @@ public void createTransaction(Player player, Merchant targetMerchant)

/**
* Toggles the movement on or off based on the input
*
* @param command either "ON" or "OFF"
*/
public void toggleMovement(String command)
Expand Down Expand Up @@ -166,7 +164,7 @@ else if(merchantNum == 2)

/**
* Main method used to test the GUI components since test classes do not maintain the GUI
* @param args
* @param args no need for input
*/
public static void main(String[] args)
{
Expand Down
23 changes: 22 additions & 1 deletion MerchantRPGCSE2102/src/controller/Transaction.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package controller;

import view.TransactionUI;
import model.Item;
import model.Merchant;
import model.Player;

Expand Down Expand Up @@ -58,14 +59,34 @@ public boolean actionSell(String itemName, int amount)

/**
* This method will push a true up to the class calling it
*
* incomplete method
* @return returns true
*/
public boolean actionCancel()
{
return true;
}

/**
* Searches the player inventory for the item matching the item name
* @param itemName name of the item
* @return returns the item with the corresponding name
*/
public Item searchPlayerInventory(String itemName)
{
return _player.getItem(itemName);
}

/**
* Searches the merchant's inventory for the item matching the item name
* @param itemName name of the item
* @return returns item with the corresponding name
*/
public Item searchMerchantInventory(String itemName)
{
return _targetMerchant.getItem(itemName);
}

/**
* Returns the player in transaction
* @return returns the player
Expand Down
6 changes: 5 additions & 1 deletion MerchantRPGCSE2102/src/view/TransactionUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void mouseClicked(MouseEvent e) {
@Override
public void mouseClicked(MouseEvent e) {
System.out.println("Cancel"); //temporary test code
MASTER.actionCancel();
exitWindow();
}
});
Expand All @@ -109,6 +110,7 @@ public void mouseClicked(MouseEvent e) {

/**
* Will exit the transaction window
* incomplete method
*/
public void exitWindow()
{
Expand Down Expand Up @@ -157,6 +159,7 @@ public static void createSellWindow()
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
String chosenItem; //item that the player chooses from the combobox
for(int i = 0; i < itemList.length; i++) //adds all the item names to the item list
{
itemList[i] = MASTER.getPlayer().getInventory()[i].getItemName();
Expand All @@ -165,8 +168,9 @@ public static void createSellWindow()
JComboBox comboBox = new JComboBox(itemList);
comboBox.setBounds(61, 141, 131, 20);
contentPane.add(comboBox);
chosenItem = comboBox.getSelectedItem().toString();

JSlider slider = new JSlider();
JSlider slider = new JSlider(0, MASTER.searchPlayerInventory(chosenItem).getQuantity(), 0); //sets the slider quantity
slider.setBounds(61, 237, 200, 26);
contentPane.add(slider);

Expand Down

0 comments on commit 346b22a

Please sign in to comment.