Skip to content

Commit

Permalink
Updated TestRPGame class
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Li committed Mar 1, 2015
1 parent f886381 commit ef93f23
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
9 changes: 6 additions & 3 deletions MerchantRPGCSE2102/src/controller/RPGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,15 @@ public ArrayList<String> getPlayerInventoryList() {
*/
public void createTransaction(Player player, Merchant targetMerchant)
{
if(_transactionLimit > 0){
if(_transactionLimit > 0)
{
toggleMovement("OFF");
Transaction newTransaction = new Transaction(player, targetMerchant);
toggleMovement("ON");
_transactionLimit -= 1;
}else{
}
else
{
System.out.println("The shops are closed.");
}
}
Expand All @@ -146,7 +149,7 @@ private void refreshTransactionLimit(){
* Will call setDailyRandomPercentage, scaleAllAdjustedPrices, refreshCash, incrementBaseCash
*
*/
private void advanceDailyCycle(){
public void advanceDailyCycle(){
Merchant[] allMerchants = {_merchant1, _merchant2, _merchant3};

_merchant1.setDailyRandomPercentage(50,200); //these methods have to be separated since they all take different percentages
Expand Down
16 changes: 16 additions & 0 deletions MerchantRPGCSE2102/src/tests/TestRPGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,21 @@ public void testDailyCycle()
{
setup();
assertEquals(1, game.getDay());
game.getMerchant(1).subtractCash(500);
assertEquals(500, game.getMerchant(1).getCurrentCash());
game.advanceDailyCycle();
assertEquals(2, game.getDay());

boolean test;
if(game.getMerchant(1).getRandomPercent() >= 50 && game.getMerchant(1).getRandomPercent() <= 200)
{
test = true;
}
else
test = false;

assertEquals(true, test);
assertEquals(1000, game.getMerchant(1).getCurrentCash());

}
}

0 comments on commit ef93f23

Please sign in to comment.