Skip to content

Commit

Permalink
added new methods as well as group discussion questions in the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Li committed Feb 2, 2015
1 parent 8ee261f commit 2ba157f
Showing 1 changed file with 49 additions and 12 deletions.
61 changes: 49 additions & 12 deletions MerchantRPGCSE2102/src/game/Merchant.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
package game;

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 Item[] _inventory;

//*************************************************************

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

//will restore the current Cash amount back to the base amount
Expand All @@ -22,14 +31,14 @@ public void refreshCash()
{
_currentCash = _baseCash;
}

//increments the base amount of cash that the merchant
//will start the day with
public void incrementCash(int incrementAmount)
{
_baseCash += incrementAmount;
}

//removes the specified amount from the merchant's current cash
public int decrementCash(int decrementAmount)
{
Expand All @@ -49,34 +58,62 @@ public int decrementCash(int decrementAmount)
return _currentCash;
}
}

//randomizer
//incomplete method
public int randomizer()
//will generate a number between 0 and max
public int randomizer(int max)
{
int randomNumber = 0;
Random randomGenerator = new Random();
randomNumber = randomGenerator.nextInt(max);
return randomNumber;
}

//will set the dailyRandomPrice to a number between the two given inputs
public void setDailyRandomPrice(int minPercent, int maxPercent)
{
//placeholder variable
int randomOutput = 0;
return randomOutput;
int randomizerVar = maxPercent - minPercent;
_dailyRandomPrice = randomizer(randomizerVar) + minPercent;
}

//************************************************************************
//given the name of the item then it will return
//the price of the item
//incomplete method
public int getItemPrice(String itemName)
{
//placeholder return
//should discuss best way to organize the item array to
//minimize the runtime needed to look up the items
int placeHolder = 0;
return placeHolder;
}
//************************************************************************

//name getter
public String getName()
{
return _name;
}

//current cash getter
public int getCurrentCash()
{
return _currentCash;
}

//base cash getter
public int getBaseCash()
{
return _baseCash;
}


//dailyRandomPrice getter
public int getRandomPrice()
{
return _dailyRandomPrice;
}

//inventory getter
public Item[] getInventory()
{
Expand Down

0 comments on commit 2ba157f

Please sign in to comment.