Skip to content

Commit

Permalink
Added buildPlayer method to RPGame
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Li committed Feb 24, 2015
1 parent ace3312 commit 4b2d037
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions MerchantRPGCSE2102/src/controller/RPGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ public void buildMerchants()
_merchant2 = new Merchant("Merchant 2", 1000, merchantInventoryList2);
_merchant3 = new Merchant("Merchant 3", 1000, merchantInventoryList3);
}

/**
* Generates the player
* @param name Player name
* @param startingCash Amount of cash the player starts with
* @param startingInventory The Player's starting inventory
*/
public void buildPlayer(String name, int startingCash, ArrayList<String> startingInventory)
{
_player = new Player(name, startingCash, startingInventory);
}

/**
* This method returns the specified merchant inventory list
Expand Down
7 changes: 6 additions & 1 deletion MerchantRPGCSE2102/src/tests/TestTransaction.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tests;

import java.util.ArrayList;

import controller.RPGame;
import junit.framework.TestCase;

Expand All @@ -12,11 +14,14 @@ public void setup()
_rpg = new RPGame();
_rpg.inventoryFromFile();
_rpg.buildMerchants();
ArrayList<String> playerInventory = _rpg.getMerchantInventoryList(1);
playerInventory.addAll(_rpg.getMerchantInventoryList(2));
playerInventory.addAll(_rpg.getMerchantInventoryList(3));
_rpg.buildPlayer("test", 500, playerInventory);
}

public void testActionSell()
{
_rpg.createTransaction(_rpg.getPlayer(), _rpg.getMerchant(1));
System.out.println("wow");
}
}

0 comments on commit 4b2d037

Please sign in to comment.