diff --git a/MerchantRPGCSE2102/src/controller/RPGame.java b/MerchantRPGCSE2102/src/controller/RPGame.java index 8f2e327..759a0d9 100644 --- a/MerchantRPGCSE2102/src/controller/RPGame.java +++ b/MerchantRPGCSE2102/src/controller/RPGame.java @@ -112,7 +112,6 @@ public void createTransaction(Player player, Merchant targetMerchant) { toggleMovement("OFF"); Transaction newTransaction = new Transaction(player, targetMerchant); - newTransaction.runTransaction(); } /** @@ -129,4 +128,28 @@ else if(command.equals("OFF")) else System.out.println("Invalid movement toggle command"); } + + /** + * Returns the player + * @return Returns the player + */ + public Player getPlayer() + { + return _player; + } + + /** + * Returns a merchant based off of the input number + * @param merchantNum The number of the merchant you want + * @return Returns the merchant that you specified + */ + public Merchant getMerchant(int merchantNum) + { + if(merchantNum == 1) + return _merchant1; + else if(merchantNum == 2) + return _merchant2; + else + return _merchant3; + } } diff --git a/MerchantRPGCSE2102/src/controller/Transaction.java b/MerchantRPGCSE2102/src/controller/Transaction.java index b7e507d..9ece05d 100644 --- a/MerchantRPGCSE2102/src/controller/Transaction.java +++ b/MerchantRPGCSE2102/src/controller/Transaction.java @@ -23,7 +23,6 @@ public Transaction(Player player, Merchant targetMerchant) */ public void runTransaction() { - _window = new TransactionUI(this); } /** @@ -65,4 +64,22 @@ public boolean actionCancel() { return true; } + + /** + * Returns the player in transaction + * @return returns the player + */ + public Player getPlayer() + { + return _player; + } + + /** + * Returns the merchant in transaction + * @return returns the merchant + */ + public Merchant getTargetMerchant() + { + return _targetMerchant; + } } diff --git a/MerchantRPGCSE2102/src/tests/TestTransaction.java b/MerchantRPGCSE2102/src/tests/TestTransaction.java index 64cfcd9..ff0709f 100644 --- a/MerchantRPGCSE2102/src/tests/TestTransaction.java +++ b/MerchantRPGCSE2102/src/tests/TestTransaction.java @@ -1,8 +1,22 @@ package tests; +import controller.RPGame; import junit.framework.TestCase; public class TestTransaction extends TestCase { - + private RPGame _rpg; + + public void setup() + { + _rpg = new RPGame(); + _rpg.inventoryFromFile(); + _rpg.buildMerchants(); + } + + public void testActionSell() + { + _rpg.createTransaction(_rpg.getPlayer(), _rpg.getMerchant(1)); + System.out.println("wow"); + } } diff --git a/MerchantRPGCSE2102/src/view/TransactionUI.java b/MerchantRPGCSE2102/src/view/TransactionUI.java index 8bf6202..b37b203 100644 --- a/MerchantRPGCSE2102/src/view/TransactionUI.java +++ b/MerchantRPGCSE2102/src/view/TransactionUI.java @@ -4,8 +4,11 @@ import java.awt.EventQueue; import javax.swing.BoxLayout; +import javax.swing.ComboBoxModel; +import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; +import javax.swing.JSlider; import javax.swing.border.EmptyBorder; import javax.swing.JButton; import javax.swing.JLabel; @@ -23,6 +26,7 @@ public class TransactionUI extends JFrame { + private static final ComboBoxModel[] Item = null; private JPanel contentPane; private static Transaction MASTER; //TransactionUI class will hold the instance of the Transaction that created it @@ -124,7 +128,7 @@ public void run() { JFrame frame = new JFrame("Buy"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - frame.setBounds(100, 100, 600, 900); + frame.setBounds(100, 100, 600, 600); JPanel contentPane = new JPanel(); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); @@ -140,17 +144,37 @@ public void run() * Will create a window for the SELL option * incomplete method */ + @SuppressWarnings({ "unchecked", "rawtypes" }) public static void createSellWindow() { JFrame frame = new JFrame("Sell"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - frame.setBounds(100, 100, 600, 900); + frame.setBounds(100, 100, 600, 600); JPanel contentPane = new JPanel(); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); frame.setContentPane(contentPane); contentPane.setLayout(null); + JComboBox comboBox = new JComboBox(MASTER.getPlayer().getInventory()); + comboBox.setBounds(61, 141, 131, 20); + contentPane.add(comboBox); + + JSlider slider = new JSlider(); + slider.setBounds(61, 237, 200, 26); + contentPane.add(slider); + + JLabel lblSelectTheItem = new JLabel("Select the Item you want:"); + lblSelectTheItem.setBounds(61, 105, 168, 14); + contentPane.add(lblSelectTheItem); + + JLabel lblSelectTheAmount = new JLabel("Select the amount:"); + lblSelectTheAmount.setBounds(61, 197, 131, 14); + contentPane.add(lblSelectTheAmount); + + JButton btnAccept = new JButton("Accept"); + btnAccept.setBounds(247, 306, 89, 23); + contentPane.add(btnAccept); frame.setVisible(true); } }