org.mars_sim.msp.core.structure.building.function
Class LifeSupport

java.lang.Object
  extended by org.mars_sim.msp.core.structure.building.function.Function
      extended by org.mars_sim.msp.core.structure.building.function.LifeSupport
All Implemented Interfaces:
Serializable

public class LifeSupport
extends Function
implements Serializable

The LifeSupport class is a building function for life support and managing inhabitants.

See Also:
Serialized Form

Field Summary
static String NAME
           
 
Constructor Summary
LifeSupport(Building building)
          Constructor
LifeSupport(Building building, int occupantCapacity, double powerRequired)
          Alternate constructor with given occupant capacity and power required.
 
Method Summary
 void addPerson(Person person)
          Adds a person to the building.
 boolean containsPerson(Person person)
          Checks if the building contains a particular person.
 void destroy()
          Prepare object for garbage collection.
 int getAvailableOccupancy()
          Gets the available occupancy room.
 double getFullPowerRequired()
          Gets the amount of power required when function is at full power.
static double getFunctionValue(String buildingName, boolean newBuilding, Settlement settlement)
          Gets the value of the function for a named building.
 int getOccupantCapacity()
          Gets the building's capacity for supporting occupants.
 int getOccupantNumber()
          Gets the current number of occupants in the building.
 Collection<Person> getOccupants()
          Gets a collection of occupants in the building.
 double getPowerDownPowerRequired()
          Gets the amount of power required when function is at power down level.
 void removePerson(Person occupant)
          Removes a person from the building.
 void timePassing(double time)
          Time passing for the building.
 
Methods inherited from class org.mars_sim.msp.core.structure.building.function.Function
getBuilding, getMalfunctionScopeStrings, getName, removeFromSettlement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final String NAME
See Also:
Constant Field Values
Constructor Detail

LifeSupport

public LifeSupport(Building building)
Constructor

Parameters:
building - the building this function is for.
Throws:
BuildingException - if error in constructing function.

LifeSupport

public LifeSupport(Building building,
                   int occupantCapacity,
                   double powerRequired)
Alternate constructor with given occupant capacity and power required.

Parameters:
building - the building this function is for.
occupantCapacity - the number of occupants this building can hold.
powerRequired - the power required (kW)
Throws:
BuildingException - if error constructing function.
Method Detail

getFunctionValue

public static double getFunctionValue(String buildingName,
                                      boolean newBuilding,
                                      Settlement settlement)
Gets the value of the function for a named building.

Parameters:
buildingName - the building name.
newBuilding - true if adding a new building.
settlement - the settlement.
Returns:
value (VP) of building function.
Throws:
Exception - if error getting function value.

getOccupantCapacity

public int getOccupantCapacity()
Gets the building's capacity for supporting occupants.

Returns:
number of inhabitants.

getOccupantNumber

public int getOccupantNumber()
Gets the current number of occupants in the building.

Returns:
occupant number

getAvailableOccupancy

public int getAvailableOccupancy()
Gets the available occupancy room.

Returns:
occupancy room

containsPerson

public boolean containsPerson(Person person)
Checks if the building contains a particular person.

Returns:
true if person is in building.

getOccupants

public Collection<Person> getOccupants()
Gets a collection of occupants in the building.

Returns:
collection of occupants

addPerson

public void addPerson(Person person)
Adds a person to the building. Note: building occupant capacity can be exceeded but stress levels in the building will increase. (todo: add stress later)

Parameters:
person - new person to add to building.
Throws:
BuildingException - if person is already building occupant.

removePerson

public void removePerson(Person occupant)
Removes a person from the building.

Parameters:
occupant - the person to remove from building.
Throws:
BuildingException - if person is not building occupant.

timePassing

public void timePassing(double time)
Time passing for the building.

Specified by:
timePassing in class Function
Parameters:
time - amount of time passing (in millisols)
Throws:
BuildingException - if error occurs.

getFullPowerRequired

public double getFullPowerRequired()
Gets the amount of power required when function is at full power.

Specified by:
getFullPowerRequired in class Function
Returns:
power (kW)

getPowerDownPowerRequired

public double getPowerDownPowerRequired()
Gets the amount of power required when function is at power down level.

Specified by:
getPowerDownPowerRequired in class Function
Returns:
power (kW)

destroy

public void destroy()
Description copied from class: Function
Prepare object for garbage collection.

Overrides:
destroy in class Function


Copyright © 2009-2013. All Rights Reserved.