|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Inventory
public class Inventory
This class represents the inventory of a ve or a vehicle or a market in our game. It keeps track of the cargo available.
Field Summary | |
---|---|
private Cargo[] |
cargo
The array of Cargo objects |
Constructor Summary | |
---|---|
Inventory()
The default constructor, creates an inventory of size equal to the maximum inventory size |
|
Inventory(int size)
The specific constructor, creates an inventory with size equal to the value passed |
Method Summary | |
---|---|
boolean |
add(Cargo goods)
Adds the cargo passed to the inventory and returns true if the addition was successful, false if not (there is no space in the inventory for it) |
boolean |
addCargo(Cargo goods)
There was some confusion over whether to name the method add() or addCargo(), so this method does the exact same thing as the add() method |
Cargo |
get(int which)
There was some confusion over whether to name the method get() or getCargo(), so this method does the exact same thing as the getCargo() method |
Cargo[] |
getCargo()
Get the Cargo value. |
Cargo |
getCargo(int which)
Returns the cargo found in the inventory at the position specified |
int |
getNumberCargos()
Returns the number of cargo in the inventory |
boolean |
isInInventory(java.lang.String type)
Determines if the cargo type specifed is in the inventory |
void |
printInventory()
Prints the contents of the inventory |
void |
printInventoryWithNumbers(double marketCostFactor)
Prints the contents of the inventory specifying the amount of each type of cargo and the cost for each type of cargo |
Cargo |
remove(int index)
There was some confusion over whether to name the method remove() or removeCargo(), so this method does the exact same thing as the removeCargo() method |
Cargo |
removeCargo(int index)
Removes and returns the cargo at the specified position from the inventory (adjusting the positions of the remaining cargo as necessary) |
void |
setCargo(Cargo[] newCargo)
Set the Cargo value. |
java.lang.String |
toString()
Returns a String representation of the contents of the inventory |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private Cargo[] cargo
Constructor Detail |
---|
public Inventory()
public Inventory(int size)
size
- An int value representing the size of the inventoryMethod Detail |
---|
public Cargo[] getCargo()
public void setCargo(Cargo[] newCargo)
newCargo
- The new Cargo value.public boolean isInInventory(java.lang.String type)
type
- A String value indicating the type of cargo to look for
public int getNumberCargos()
public boolean addCargo(Cargo goods)
goods
- the cargo to add to the Inventory.
public boolean add(Cargo goods)
goods
- the cargo to add to the Inventory.
public Cargo remove(int index)
index
- The position in the array, of the cargo to be removed
public Cargo removeCargo(int index)
index
- The position in the array, of the cargo to be removed
public java.lang.String toString()
toString
in class java.lang.Object
public void printInventory()
public void printInventoryWithNumbers(double marketCostFactor)
marketCostFactor
- A double value indicating the cost factor at the
current marketpublic Cargo get(int which)
which
- The position in the array of the cargo to be returned
public Cargo getCargo(int which)
which
- The position in the array of the cargo to be returned
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |