diff --git a/MerchantRPGCSE2102/src/game/Merchant.java b/MerchantRPGCSE2102/src/game/Merchant.java index f752f50..ceaf9a6 100644 --- a/MerchantRPGCSE2102/src/game/Merchant.java +++ b/MerchantRPGCSE2102/src/game/Merchant.java @@ -1,5 +1,6 @@ package game; +import java.util.ArrayList; import java.util.Random; public class Merchant @@ -7,22 +8,17 @@ 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 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 @@ -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; } //************************************************************************ @@ -111,7 +107,7 @@ public int getBaseCash() //dailyRandomPrice getter public int getRandomPrice() { - return _dailyRandomPrice; + return _dailyRandomPercent; } //inventory getter diff --git a/MerchantRPGCSE2102/src/tests/TestMerchant.java b/MerchantRPGCSE2102/src/tests/TestMerchant.java index 91c84ea..7c04c06 100644 --- a/MerchantRPGCSE2102/src/tests/TestMerchant.java +++ b/MerchantRPGCSE2102/src/tests/TestMerchant.java @@ -1,5 +1,7 @@ package tests; +import java.util.ArrayList; + import game.Merchant; import junit.framework.TestCase; @@ -10,7 +12,8 @@ public class TestMerchant extends TestCase public void setup() { - m = new Merchant("Test", 100, 2); + ArrayList a = new ArrayList(); + m = new Merchant("Test", 100, a); } //testing cash system