Skip to content

Commit

Permalink
Merchant & TestMerchant:
Browse files Browse the repository at this point in the history
* changed member variable name from dailyRandomPrice to
dailyRandomPercent and changed variable name in setDailyRandomPercent as
dicussed in the previous team meeting.
*Changed Merchant constructor to utilize the new ArrayLists of item
names in the RPGame class. Updated the TestMerchant class to reflect
these changes.
  • Loading branch information
Gavin Li committed Feb 9, 2015
1 parent 73bc733 commit d82bba6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
18 changes: 7 additions & 11 deletions MerchantRPGCSE2102/src/game/Merchant.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
package game;

import java.util.ArrayList;
import java.util.Random;

public class Merchant
{
private String _name;
private int _currentCash;
private int _baseCash;
private int _dailyRandomPrice;
//*************************************************************
//should we use an array of items or maybe a linked list?
//further discussion with group needed
private int _dailyRandomPercent;
private Item[] _inventory;
//*************************************************************

//merchant constructor
public Merchant(String name, int cashLimit, int inventorySize)
public Merchant(String name, int cashLimit, ArrayList<String> inventory)
{
_name = name;
_currentCash = cashLimit;
_baseCash = cashLimit;
_inventory = new Item[inventorySize];
//placeholder number
_dailyRandomPrice = 0;
_dailyRandomPercent = 0;
}

//will restore the current Cash amount back to the base amount
Expand Down Expand Up @@ -72,8 +68,8 @@ public int randomizer(int max)
//will set the dailyRandomPrice to a number between the two given inputs
public void setDailyRandomPrice(int minPercent, int maxPercent)
{
int randomizerVar = maxPercent - minPercent;
_dailyRandomPrice = randomizer(randomizerVar) + minPercent;
int randomizerRange = maxPercent - minPercent;
_dailyRandomPercent = randomizer(randomizerRange) + minPercent;
}

//************************************************************************
Expand Down Expand Up @@ -111,7 +107,7 @@ public int getBaseCash()
//dailyRandomPrice getter
public int getRandomPrice()
{
return _dailyRandomPrice;
return _dailyRandomPercent;
}

//inventory getter
Expand Down
5 changes: 4 additions & 1 deletion MerchantRPGCSE2102/src/tests/TestMerchant.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tests;

import java.util.ArrayList;

import game.Merchant;
import junit.framework.TestCase;

Expand All @@ -10,7 +12,8 @@ public class TestMerchant extends TestCase

public void setup()
{
m = new Merchant("Test", 100, 2);
ArrayList a = new ArrayList<String>();
m = new Merchant("Test", 100, a);
}

//testing cash system
Expand Down

0 comments on commit d82bba6

Please sign in to comment.