org.mars_sim.msp.core.structure.building
Class Building

java.lang.Object
  extended by org.mars_sim.msp.core.structure.building.Building
All Implemented Interfaces:
Serializable, Comparable<Building>, LocalBoundedObject, Malfunctionable

public class Building
extends Object
implements Malfunctionable, Serializable, Comparable<Building>, LocalBoundedObject

The Building class is a settlement's building.

See Also:
Serialized Form

Field Summary
protected  double basePowerDownPowerRequirement
           
protected  double basePowerRequirement
           
protected  double facing
           
static String FULL_POWER
           
protected  List<Function> functions
           
protected  double length
           
protected  MalfunctionManager malfunctionManager
           
protected  BuildingManager manager
           
protected  String name
           
static String NO_POWER
           
static String POWER_DOWN
           
protected  String powerMode
           
protected  double width
           
protected  double xLoc
           
protected  double yLoc
           
 
Constructor Summary
protected Building()
          Empty constructor.
  Building(BuildingTemplate template, BuildingManager manager)
          Constructs a Building object.
  Building(String name, double xLoc, double yLoc, double facing, BuildingManager manager)
          Constructs a Building object.
 
Method Summary
 int compareTo(Building o)
          Compares this object with the specified object for order.
 void destroy()
          Prepare object for garbage collection.
 Collection<Person> getAffectedPeople()
          Gets a collection of people affected by this entity.
 BuildingManager getBuildingManager()
          Gets the building's building manager.
 double getFacing()
          Gets the object's facing.
 double getFullPowerRequired()
          Gets the power this building currently requires for full-power mode.
 Function getFunction(String functionName)
          Gets a function if the building has it.
 Inventory getInventory()
          Gets the inventory associated with this entity.
 double getLength()
          Gets the object's length.
 MalfunctionManager getMalfunctionManager()
          Gets the entity's malfunction manager.
 String getName()
          Gets the building's name.
 double getPoweredDownPowerRequired()
          Gets the power the building requires for power-down mode.
 String getPowerMode()
          Gets the building's power mode.
 double getWidth()
          Gets the object's width.
 double getXLocation()
          Gets the X location of the object from the local area's center point.
 double getYLocation()
          Gets the Y location of the object from the local area's center point.
 boolean hasFunction(String functionName)
          Checks if a building has a particular function.
 void removeFunctionsFromSettlement()
          Remove the building's functions from the settlement.
 void setPowerMode(String powerMode)
          Sets the building's power mode.
 void timePassing(double time)
          Time passing for building.
 String toString()
          String representation of this building.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FULL_POWER

public static final String FULL_POWER
See Also:
Constant Field Values

POWER_DOWN

public static final String POWER_DOWN
See Also:
Constant Field Values

NO_POWER

public static final String NO_POWER
See Also:
Constant Field Values

manager

protected BuildingManager manager

name

protected String name

width

protected double width

length

protected double length

xLoc

protected double xLoc

yLoc

protected double yLoc

facing

protected double facing

powerMode

protected String powerMode

malfunctionManager

protected MalfunctionManager malfunctionManager

functions

protected List<Function> functions

basePowerRequirement

protected double basePowerRequirement

basePowerDownPowerRequirement

protected double basePowerDownPowerRequirement
Constructor Detail

Building

public Building(BuildingTemplate template,
                BuildingManager manager)
Constructs a Building object.

Parameters:
template - the building template.
manager - the building's building manager.
Throws:
BuildingException - if building can not be created.

Building

public Building(String name,
                double xLoc,
                double yLoc,
                double facing,
                BuildingManager manager)
Constructs a Building object.

Parameters:
name - the building's name.
xLoc - the x location of the building in the settlement.
yLoc - the y location of the building in the settlement.
facing - the facing of the building (degrees clockwise from North).
manager - the building's building manager.
Throws:
BuildingException - if building can not be created.

Building

protected Building()
Empty constructor.

Method Detail

hasFunction

public boolean hasFunction(String functionName)
Checks if a building has a particular function.

Parameters:
functionName - the name of the function.
Returns:
true if function.

getFunction

public Function getFunction(String functionName)
Gets a function if the building has it.

Parameters:
functionName - the name of the function.
Returns:
function.
Throws:
BuildingException - if building doesn't have the function.

removeFunctionsFromSettlement

public void removeFunctionsFromSettlement()
Remove the building's functions from the settlement.


getBuildingManager

public BuildingManager getBuildingManager()
Gets the building's building manager.

Returns:
building manager

getName

public String getName()
Gets the building's name.

Specified by:
getName in interface Malfunctionable
Returns:
building's name as a String.

getWidth

public double getWidth()
Description copied from interface: LocalBoundedObject
Gets the object's width.

Specified by:
getWidth in interface LocalBoundedObject
Returns:
width (meters).

getLength

public double getLength()
Description copied from interface: LocalBoundedObject
Gets the object's length.

Specified by:
getLength in interface LocalBoundedObject
Returns:
length (meters).

getXLocation

public double getXLocation()
Description copied from interface: LocalBoundedObject
Gets the X location of the object from the local area's center point.

Specified by:
getXLocation in interface LocalBoundedObject
Returns:
X location (meters from local center point - West: positive, East: negative).

getYLocation

public double getYLocation()
Description copied from interface: LocalBoundedObject
Gets the Y location of the object from the local area's center point.

Specified by:
getYLocation in interface LocalBoundedObject
Returns:
Y location (meters from local center point - North: positive, South: negative).

getFacing

public double getFacing()
Description copied from interface: LocalBoundedObject
Gets the object's facing.

Specified by:
getFacing in interface LocalBoundedObject
Returns:
facing (degrees from North clockwise).

timePassing

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

Parameters:
time - amount of time passing (in millisols)
Throws:
BuildingException - if error occurs.

getFullPowerRequired

public double getFullPowerRequired()
Gets the power this building currently requires for full-power mode.

Returns:
power in kW.

getPoweredDownPowerRequired

public double getPoweredDownPowerRequired()
Gets the power the building requires for power-down mode.

Returns:
power in kW.

getPowerMode

public String getPowerMode()
Gets the building's power mode.


setPowerMode

public void setPowerMode(String powerMode)
Sets the building's power mode.


getMalfunctionManager

public MalfunctionManager getMalfunctionManager()
Gets the entity's malfunction manager.

Specified by:
getMalfunctionManager in interface Malfunctionable
Returns:
malfunction manager

getAffectedPeople

public Collection<Person> getAffectedPeople()
Gets a collection of people affected by this entity. Children buildings should add additional people as necessary.

Specified by:
getAffectedPeople in interface Malfunctionable
Returns:
person collection

getInventory

public Inventory getInventory()
Gets the inventory associated with this entity.

Specified by:
getInventory in interface Malfunctionable
Returns:
inventory

toString

public String toString()
String representation of this building.

Overrides:
toString in class Object
Returns:
The settlement and building name.

compareTo

public int compareTo(Building o)
Compares this object with the specified object for order.

Specified by:
compareTo in interface Comparable<Building>
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

destroy

public void destroy()
Prepare object for garbage collection.



Copyright © 2009-2013. All Rights Reserved.