|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Inventory
public class Inventory
Field Summary | |
---|---|
private static int |
AMMO_POS
The value corresponding to ammunition in the inventory |
private int |
ammunition
The amount of ammunition in the Inventory |
private int |
food
The amount of food available in the Inventory |
private static int |
FOOD_POS
The value corresponding to food in the inventory |
private double |
money
The amount of money available in the Inventory. |
private static int |
MONEY_POS
The value corresponding to money in the inventory |
private static int |
NUM_ITEMS
total number of items in inventory |
private int |
oxen
The amount of propulsion (oxen, rockets, etc. |
private static int |
OXEN_POS
The value corresponding to any form of propulsion in the inventory |
Constructor Summary | |
---|---|
Inventory()
Default constructor |
|
Inventory(int theFood,
double theMoney,
int theAmmo,
int theOxen)
Specific four-parameter constructor. |
Method Summary | |
---|---|
void |
add(int item,
int amount)
Adds specified amount of item to Inventory This applies only to tradeable items: food, ammunition, and propulsion Items may correspond to FOOD_POS ,AMMO_POS , or OXEN_POS |
int |
getAmmunition()
|
int |
getAmount(int item)
Returns the amount of the specified item. |
double |
getCost(int item,
double priceFactor)
Returns the cost of the item at the current Depot's price factor. |
int |
getFood()
|
double |
getMoney()
|
static int |
getNumItems()
|
int |
getOxen()
|
void |
printInventory(double priceFactor)
Prints the Inventory and displays the amount of money available. |
void |
printInventory(double priceFactor,
boolean showMoney)
Prints the Inventory, possibly displaying the amount of money available |
void |
remove(int item)
Removes ALL of a particular item type from an Inventory This applies only to tradeable items: food, ammunition, and propulsion Items may correspond to FOOD_POS ,AMMO_POS , or OXEN_POS |
void |
remove(int item,
int amount)
Removes specified amount of a particular item from an Inventory This applies only to tradeable items: food, ammunition, and propulsion Items may correspond to FOOD_POS ,AMMO_POS , or OXEN_POS |
void |
setAmmunition(int ammunition)
|
void |
setFood(int food)
|
void |
setMoney(double money)
|
void |
setOxen(int oxen)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int MONEY_POS
private static final int FOOD_POS
private static final int AMMO_POS
private static final int OXEN_POS
private static final int NUM_ITEMS
private int food
private double money
Game.STARTING_MONEY
private int ammunition
private int oxen
Constructor Detail |
---|
public Inventory()
public Inventory(int theFood, double theMoney, int theAmmo, int theOxen)
theFood
- The amount of food to initialize the Inventory withtheMoney
- The amount of money to initialize the Inventory withtheAmmo
- The amount of ammunittion to initalize the Inventory withtheOxen
- The number of propulsion units (oxen, rockets, etc.) to initialize the Inventory with.Method Detail |
---|
public int getAmmunition()
public void setAmmunition(int ammunition)
ammunition
- The ammunition to set.public int getFood()
public void setFood(int food)
food
- The food to set.public double getMoney()
public void setMoney(double money)
money
- The money to set.public int getOxen()
public void setOxen(int oxen)
oxen
- The oxen to set.public static int getNumItems()
public double getCost(int item, double priceFactor)
Game.DEFAULT_FOOD_COST
, Game.DEFAULT_AMMO_COST
,
or Game.DEFAULT_OXEN_COST
, depending on which item is specified.
If an invalid item number is provided, then -1.0 is returned.
item
- The item ID number which specifies which type of item.priceFactor
- The market factor for the depot.
public int getAmount(int item)
item
- The item type
public void remove(int item)
FOOD_POS
,AMMO_POS
, or OXEN_POS
item
- The item typepublic void remove(int item, int amount)
FOOD_POS
,AMMO_POS
, or OXEN_POS
item
- The item typeamount
- The amount of the item to removepublic void add(int item, int amount)
FOOD_POS
,AMMO_POS
, or OXEN_POS
item
- The item type to add to the Inventoryamount
- The amount of the item to add to the Inventorypublic void printInventory(double priceFactor)
printInventory(double priceFactor, boolean showMoney)
priceFactor
- The Depot's price factorpublic void printInventory(double priceFactor, boolean showMoney)
priceFactor
- The Depot's price factorshowMoney
- Flag to indicate whether to display the amount of money available.
If true, display money. If false, do not display money.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |