org.mars_sim.msp.core.person
Class Person

java.lang.Object
  extended by org.mars_sim.msp.core.Unit
      extended by org.mars_sim.msp.core.person.Person
All Implemented Interfaces:
Serializable, Comparable<Unit>, VehicleOperator

public class Person
extends Unit
implements VehicleOperator, 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 String ASSOCIATED_SETTLEMENT_EVENT
           
static String BURIED
          Status string used when Person has been buried
static String FEMALE
           
static String INSETTLEMENT
          Status string used when Person resides in settlement
static String INVEHICLE
          Status string used when Person resides in a vehicle
static String MALE
           
static String OUTSIDE
          Status string used when Person is outside
 
Fields inherited from class org.mars_sim.msp.core.Unit
CONTAINER_UNIT_EVENT, DESCRIPTION_EVENT, LOCATION_EVENT, MASS_EVENT, NAME_EVENT
 
Constructor Summary
Person(String name, String gender, Settlement settlement)
          Constructs a Person object at a given settlement
 
Method Summary
 void addScientificAchievement(double achievementCredit, Science science)
          Add achievement credit to the person in a scientific field.
 void buryBody()
          Bury the Person at the current location.
 void consumeFood(double amount, boolean takeFromInv)
          Person consumes given amount of food
 void destroy()
          Prepare object for garbage collection.
 int getAge()
          Returns the person's age
 Settlement getAssociatedSettlement()
          Gets the settlement the person is currently associated with.
 String getBirthDate()
          Returns the person's birth date
 String getGender()
          Gets the gender of the person ("male" or "female")
 Collection<Person> getLocalGroup()
          Gets the person's local group of people (in building or rover)
 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
 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
 double getScientificAchievement(Science science)
          Gets the person's achievement credit for a given scientific field.
 Settlement getSettlement()
          Get settlement person is at, null if person is not at a settlement
 double getTotalScientificAchievement()
          Gets the person's total scientific achievement credit.
 Vehicle getVehicle()
          Get vehicle person is in, null if person is not in vehicle
 double getXLocation()
          Gets the person's X location at a settlement.
 double getYLocation()
          Gets the person's Y location at a settlement.
 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 setXLocation(double xLocation)
          Sets the person's X location at a settlement.
 void setYLocation(double yLocation)
          Sets the person's Y location at a settlement.
 void timePassing(double time)
          Person can take action with time passing
 
Methods inherited from class org.mars_sim.msp.core.Unit
addUnitListener, compareTo, fireUnitUpdate, fireUnitUpdate, getBaseMass, getContainerUnit, getCoordinates, getDescription, getInventory, getMass, getName, getTopContainerUnit, getUnitManager, hasUnitListener, 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 String ASSOCIATED_SETTLEMENT_EVENT
See Also:
Constant Field Values

INSETTLEMENT

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

See Also:
Constant Field Values

INVEHICLE

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

See Also:
Constant Field Values

OUTSIDE

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

See Also:
Constant Field Values

BURIED

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

See Also:
Constant Field Values

MALE

public static final String MALE
See Also:
Constant Field Values

FEMALE

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

Person

public Person(String name,
              String gender,
              Settlement settlement)
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:
Exception - if no inhabitable building available at settlement.
Method Detail

getLocationSituation

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

Returns:
the person's location

getXLocation

public double getXLocation()
Gets the person's X location at a settlement.

Returns:
X distance (meters) from the settlement's center.

setXLocation

public void setXLocation(double xLocation)
Sets the person's X location at a settlement.

Parameters:
xLocation - the X distance (meters) from the settlement's center.

getYLocation

public double getYLocation()
Gets the person's Y location at a settlement.

Returns:
Y distance (meters) from the settlement's center.

setYLocation

public void setYLocation(double yLocation)
Sets the person's Y location at a settlement.

Parameters:
yLocation -

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)
Person can take action with time passing

Overrides:
timePassing in class Unit
Parameters:
time - amount of time passing (in millisols).

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

getAge

public int getAge()
Returns the person's age

Returns:
the person's age

getBirthDate

public String getBirthDate()
Returns the person's birth date

Returns:
the person's birth date

consumeFood

public void consumeFood(double amount,
                        boolean takeFromInv)
Person consumes given amount of food

Parameters:
amount - the amount of food to consume (in kg)
takeFromInv - is food taken from local inventory?

getGender

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

Returns:
the gender

getLocalGroup

public Collection<Person> getLocalGroup()
Gets the person's local group of people (in building or rover)

Returns:
collection of people in person's location.

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 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.

getScientificAchievement

public double getScientificAchievement(Science science)
Gets the person's achievement credit for a given scientific field.

Parameters:
science - the scientific field.
Returns:
achievement credit.

getTotalScientificAchievement

public double getTotalScientificAchievement()
Gets the person's total scientific achievement credit.

Returns:
achievement credit.

addScientificAchievement

public void addScientificAchievement(double achievementCredit,
                                     Science science)
Add achievement credit to the person in a scientific field.

Parameters:
achievementCredit - the achievement credit.
science - the scientific field.

destroy

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

Overrides:
destroy in class Unit


Copyright © 2009-2013. All Rights Reserved.