|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mars_sim.msp.simulation.Inventory
public class Inventory
The Inventory class represents what a unit contains in terms of resources and other units. It has methods for adding, removing and querying what the unit contains.
Field Summary | |
---|---|
static java.lang.String |
INVENTORY_RESOURCE_EVENT
|
static java.lang.String |
INVENTORY_RETRIEVING_UNIT_EVENT
|
static java.lang.String |
INVENTORY_STORING_UNIT_EVENT
|
Constructor Summary | |
---|---|
Inventory(Unit owner)
Constructor |
Method Summary | |
---|---|
void |
addAmountResourcePhaseCapacity(Phase phase,
double capacity)
Adds capacity for a resource phase. |
void |
addAmountResourceTypeCapacity(AmountResource resource,
double capacity)
Adds capacity for a resource type. |
void |
addGeneralCapacity(double capacity)
Adds a capacity to general capacity. |
boolean |
canStoreUnit(Unit unit)
Checks if a unit can be stored. |
Inventory |
clone(Unit owner)
Creates a clone of this inventory (not including the inventory contents). |
boolean |
containsUnit(Unit unit)
Checks if a unit is in storage. |
boolean |
containsUnitClass(java.lang.Class unitClass)
Checks if any of a given class of unit is in storage. |
java.util.Collection<Unit> |
findAllUnitsOfClass(java.lang.Class unitClass)
Finds all of the units of a class in storage. |
int |
findNumEmptyUnitsOfClass(java.lang.Class unitClass)
Finds the number of units of a class that are contained in storage and have an empty inventory. |
int |
findNumUnitsOfClass(java.lang.Class unitClass)
Finds the number of units of a class that are contained in storage. |
Unit |
findUnitOfClass(java.lang.Class unitClass)
Finds a unit of a given class in storage. |
java.util.Set<AmountResource> |
getAllAmountResourcesStored()
Gets all of the amount resources stored. |
java.util.Set<ItemResource> |
getAllItemResourcesStored()
Gets a set of all the item resources in storage. |
double |
getAmountResourceCapacity(AmountResource resource)
Gets the storage capacity for a resource. |
double |
getAmountResourceRemainingCapacity(AmountResource resource,
boolean useContainedUnits)
Gets the remaining capacity available for a resource. |
double |
getAmountResourceStored(AmountResource resource)
Gets the amount of a resource stored. |
java.util.Collection<Unit> |
getContainedUnits()
Gets a collection of all the stored units. |
double |
getGeneralCapacity()
Gets the general capacity. |
double |
getGeneralStoredMass()
Gets the mass stored in general capacity. |
int |
getItemResourceNum(ItemResource resource)
Gets the number of an item resource in storage. |
double |
getRemainingGeneralCapacity()
Gets the remaining general capacity available. |
double |
getTotalInventoryMass()
Gets the total mass stored in inventory. |
double |
getUnitTotalMass()
Gets the total unit mass in storage. |
boolean |
hasAmountResourceCapacity(AmountResource resource)
Checks if storage has capacity for a resource. |
boolean |
hasAmountResourceCapacity(AmountResource resource,
double amount)
Checks if storage has capacity for an amount of a resource. |
boolean |
hasItemResource(ItemResource resource)
Checks if storage has an item resource. |
boolean |
isEmpty()
Checks if inventory is empty. |
void |
retrieveAmountResource(AmountResource resource,
double amount)
Retrieves an amount of a resource from storage. |
void |
retrieveItemResources(ItemResource resource,
int number)
Retrieves item resources. |
void |
retrieveUnit(Unit unit)
Retrieves a unit from storage. |
void |
setCoordinates(Coordinates newLocation)
Sets the coordinates of all units in the inventory. |
void |
storeAmountResource(AmountResource resource,
double amount,
boolean useContainedUnits)
Store an amount of a resource. |
void |
storeItemResources(ItemResource resource,
int number)
Stores item resources. |
void |
storeUnit(Unit unit)
Stores a unit. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String INVENTORY_STORING_UNIT_EVENT
public static final java.lang.String INVENTORY_RETRIEVING_UNIT_EVENT
public static final java.lang.String INVENTORY_RESOURCE_EVENT
Constructor Detail |
---|
public Inventory(Unit owner)
owner
- the unit that owns this inventoryMethod Detail |
---|
public void addAmountResourceTypeCapacity(AmountResource resource, double capacity) throws InventoryException
resource
- the resource.capacity
- the capacity amount (kg).
InventoryException
- if error setting capacity.public void addAmountResourcePhaseCapacity(Phase phase, double capacity) throws InventoryException
phase
- the phasecapacity
- the capacity amount (kg).
InventoryException
- if error adding capacity.public boolean hasAmountResourceCapacity(AmountResource resource) throws InventoryException
resource
- the resource.
InventoryException
public boolean hasAmountResourceCapacity(AmountResource resource, double amount) throws InventoryException
resource
- the resource.amount
- the amount (kg).
InventoryException
- if error checking capacity.public double getAmountResourceCapacity(AmountResource resource) throws InventoryException
resource
- the resource.
InventoryException
- if error determining capacity.public double getAmountResourceStored(AmountResource resource) throws InventoryException
resource
- the resource.
InventoryException
- if error getting amount stored.public java.util.Set<AmountResource> getAllAmountResourcesStored() throws InventoryException
InventoryException
- if error getting all amount resources.public double getAmountResourceRemainingCapacity(AmountResource resource, boolean useContainedUnits) throws InventoryException
resource
- the resource.useContainedUnits
- should the capacity of contained units be added?
InventoryException
public void storeAmountResource(AmountResource resource, double amount, boolean useContainedUnits) throws InventoryException
resource
- the resource.amount
- the amount (kg).
InventoryException
- if error storing resource.public void retrieveAmountResource(AmountResource resource, double amount) throws InventoryException
resource
- the resource.amount
- the amount (kg).
InventoryException
- if error retrieving resource.public void addGeneralCapacity(double capacity)
capacity
- amount capacity (kg).public double getGeneralCapacity()
public double getGeneralStoredMass() throws InventoryException
InventoryException
- if error getting stored mass.public double getRemainingGeneralCapacity() throws InventoryException
InventoryException
- if error getting remaining capacity.public boolean hasItemResource(ItemResource resource) throws InventoryException
resource
- the resource.
InventoryException
- if error checking resource.public int getItemResourceNum(ItemResource resource) throws InventoryException
resource
- the resource.
InventoryException
- if error getting item resource.public java.util.Set<ItemResource> getAllItemResourcesStored() throws InventoryException
InventoryException
- if error getting all item resources.public void storeItemResources(ItemResource resource, int number) throws InventoryException
resource
- the resource to store.number
- the number of resources to store.
InventoryException
- if error storing the resources.public void retrieveItemResources(ItemResource resource, int number) throws InventoryException
resource
- the resource to retrieve.number
- the number of resources to retrieve.
InventoryException
- if error retrieving the resources.public double getUnitTotalMass() throws InventoryException
InventoryException
- if error getting mass.public java.util.Collection<Unit> getContainedUnits()
public boolean containsUnit(Unit unit)
unit
- the unit.
public boolean containsUnitClass(java.lang.Class unitClass)
unitClass
- the unit class.
public Unit findUnitOfClass(java.lang.Class unitClass)
unitClass
- the unit class.
public java.util.Collection<Unit> findAllUnitsOfClass(java.lang.Class unitClass)
unitClass
- the unit class.
public int findNumUnitsOfClass(java.lang.Class unitClass)
unitClass
- the unit class.
public int findNumEmptyUnitsOfClass(java.lang.Class unitClass) throws InventoryException
unitClass
- the unit class.
InventoryException
- if error determining number of units.public boolean canStoreUnit(Unit unit) throws InventoryException
unit
- the unit.
InventoryException
- if error checking unit.public void storeUnit(Unit unit) throws InventoryException
unit
- the unit
InventoryException
- if unit could not be stored.public void retrieveUnit(Unit unit) throws InventoryException
unit
- the unit.
InventoryException
- if unit could not be retrieved.public void setCoordinates(Coordinates newLocation)
newLocation
- the new coordinate locationpublic double getTotalInventoryMass() throws InventoryException
InventoryException
- if error getting mass.public boolean isEmpty() throws InventoryException
InventoryException
- if error checking inventory.public Inventory clone(Unit owner) throws InventoryException
owner
- the unit owner of the inventory (or null).
InventoryException
- if error creating inventory clone.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |