org.mars_sim.msp.simulation.person
Class Person

java.lang.Object
  extended by org.mars_sim.msp.simulation.Unit
      extended by org.mars_sim.msp.simulation.person.Person
All Implemented Interfaces:
java.io.Serializable, VehicleOperator

public class Person
extends Unit
implements VehicleOperator, java.io.Serializable

The Person class represents a person on Mars. It keeps track of everything related to that person and provides information about him/her.

See Also:
Serialized Form

Field Summary
static java.lang.String ASSOCIATED_SETTLEMENT_EVENT
           
static java.lang.String BURIED
          Status string used when Person has been buried
static java.lang.String FEMALE
           
static java.lang.String INSETTLEMENT
          Status string used when Person resides in settlement
static java.lang.String INVEHICLE
          Status string used when Person resides in a vehicle
static java.lang.String MALE
           
static java.lang.String OUTSIDE
          Status string used when Person is outside
 
Fields inherited from class org.mars_sim.msp.simulation.Unit
CONTAINER_UNIT_EVENT, DESCRIPTION_EVENT, LOCATION_EVENT, MASS_EVENT, NAME_EVENT
 
Constructor Summary
Person(java.lang.String name, java.lang.String gender, Settlement settlement)
          Constructs a Person object at a given settlement
 
Method Summary
 void buryBody()
          Bury the Person at the current location.
 void consumeFood(double amount, boolean takeFromInv)
          Person consumes given amount of food
 Settlement getAssociatedSettlement()
          Gets the settlement the person is currently associated with.
 java.lang.String getGender()
          Gets the gender of the person ("male" or "female")
 java.util.Collection<Person> getLocalGroup()
          Gets the person's local group of people (in building or rover)
 java.lang.String getLocationSituation()
          Returns a string for the person's relative location "In Settlement", "In Vehicle", "Outside" or "Buried"
 Mind getMind()
          Returns the person's mind
 NaturalAttributeManager getNaturalAttributeManager()
          Returns a reference to the Person's natural attribute manager
 java.lang.String getOperatorName()
          Gets the name of the vehicle operator
 double getPerformanceRating()
          Get the performance factor that effect Person with the complaint.
 PhysicalCondition getPhysicalCondition()
          Returns a reference to the Person's physical condition
 Settlement getSettlement()
          Get settlement person is at, null if person is not at a settlement
 Vehicle getVehicle()
          Get vehicle person is in, null if person is not in vehicle
 boolean isFitForOperatingVehicle()
          Checks if the vehicle operator is fit for operating the vehicle.
 void setAssociatedSettlement(Settlement newSettlement)
          Sets the associated settlement for a person.
 void setContainerUnit(Unit containerUnit)
          Sets the unit's container unit.
 void timePassing(double time)
          Person can take action with time passing
 
Methods inherited from class org.mars_sim.msp.simulation.Unit
addUnitListener, fireUnitUpdate, fireUnitUpdate, getBaseMass, getContainerUnit, getCoordinates, getDescription, getInventory, getMass, getName, getTopContainerUnit, getUnitManager, removeUnitListener, setBaseMass, setCoordinates, setDescription, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ASSOCIATED_SETTLEMENT_EVENT

public static final java.lang.String ASSOCIATED_SETTLEMENT_EVENT
See Also:
Constant Field Values

INSETTLEMENT

public static final java.lang.String INSETTLEMENT
Status string used when Person resides in settlement

See Also:
Constant Field Values

INVEHICLE

public static final java.lang.String INVEHICLE
Status string used when Person resides in a vehicle

See Also:
Constant Field Values

OUTSIDE

public static final java.lang.String OUTSIDE
Status string used when Person is outside

See Also:
Constant Field Values

BURIED

public static final java.lang.String BURIED
Status string used when Person has been buried

See Also:
Constant Field Values

MALE

public static final java.lang.String MALE
See Also:
Constant Field Values

FEMALE

public static final java.lang.String FEMALE
See Also:
Constant Field Values
Constructor Detail

Person

public Person(java.lang.String name,
              java.lang.String gender,
              Settlement settlement)
       throws java.lang.Exception
Constructs a Person object at a given settlement

Parameters:
name - the person's name
gender - the person's gender ("male" or "female")
settlement - the settlement the person is at
Throws:
java.lang.Exception - if no inhabitable building available at settlement.
Method Detail

getLocationSituation

public java.lang.String getLocationSituation()
Returns a string for the person's relative location "In Settlement", "In Vehicle", "Outside" or "Buried"

Returns:
the person's location

getSettlement

public Settlement getSettlement()
Get settlement person is at, null if person is not at a settlement

Returns:
the person's settlement

getVehicle

public Vehicle getVehicle()
Get vehicle person is in, null if person is not in vehicle

Returns:
the person's vehicle

setContainerUnit

public void setContainerUnit(Unit containerUnit)
Sets the unit's container unit. Overridden from Unit class.

Overrides:
setContainerUnit in class Unit
Parameters:
containerUnit - the unit to contain this unit.

buryBody

public void buryBody()
Bury the Person at the current location. The person is removed from any containing Settlements or Vehicles. The body is fixed at the last location of the containing unit.


timePassing

public void timePassing(double time)
                 throws java.lang.Exception
Person can take action with time passing

Overrides:
timePassing in class Unit
Parameters:
time - amount of time passing (in millisols) throws Exception if error during time.
Throws:
java.lang.Exception - if error during time passing.

getNaturalAttributeManager

public NaturalAttributeManager getNaturalAttributeManager()
Returns a reference to the Person's natural attribute manager

Returns:
the person's natural attribute manager

getPerformanceRating

public double getPerformanceRating()
Get the performance factor that effect Person with the complaint.

Returns:
The value is between 0 -> 1.

getPhysicalCondition

public PhysicalCondition getPhysicalCondition()
Returns a reference to the Person's physical condition

Returns:
the person's physical condition

getMind

public Mind getMind()
Returns the person's mind

Returns:
the person's mind

consumeFood

public void consumeFood(double amount,
                        boolean takeFromInv)
                 throws java.lang.Exception
Person consumes given amount of food

Parameters:
amount - amount of food to consume (in kg)
takeFromInv - is food taken from local inventory?
Throws:
java.lang.Exception - if error consuming food.

getGender

public java.lang.String getGender()
Gets the gender of the person ("male" or "female")

Returns:
the gender

getLocalGroup

public java.util.Collection<Person> getLocalGroup()
                                           throws java.lang.Exception
Gets the person's local group of people (in building or rover)

Returns:
collection of people in person's location.
Throws:
java.lang.Exception - if error

isFitForOperatingVehicle

public boolean isFitForOperatingVehicle()
Checks if the vehicle operator is fit for operating the vehicle.

Specified by:
isFitForOperatingVehicle in interface VehicleOperator
Returns:
true if vehicle operator is fit.

getOperatorName

public java.lang.String getOperatorName()
Gets the name of the vehicle operator

Specified by:
getOperatorName in interface VehicleOperator
Returns:
vehicle operator name.

getAssociatedSettlement

public Settlement getAssociatedSettlement()
Gets the settlement the person is currently associated with.

Returns:
associated settlement or null if none.

setAssociatedSettlement

public void setAssociatedSettlement(Settlement newSettlement)
Sets the associated settlement for a person.

Parameters:
newSettlement - the new associated settlement or null if none.