org.mars_sim.msp.simulation.structure.building.function
Class Crop

java.lang.Object
  extended by org.mars_sim.msp.simulation.structure.building.function.Crop
All Implemented Interfaces:
java.io.Serializable

public class Crop
extends java.lang.Object
implements java.io.Serializable

The Crop class is a food crop grown on a farm.

See Also:
Serialized Form

Field Summary
static double CARBON_DIOXIDE_NEEDED
           
static java.lang.String FINISHED
           
static java.lang.String GROWING
           
static java.lang.String HARVESTING
           
static java.lang.String PLANTING
           
static double WASTE_WATER_NEEDED
           
 
Constructor Summary
Crop(CropType cropType, double maxHarvest, Farming farm, Settlement settlement, boolean newCrop)
          Constructor
 
Method Summary
 double addWork(double workTime)
          Adds work time to the crops current phase.
static double getAverageCropGrowingTime()
          Gets the average growing time for a crop.
 double getCondition()
          Gets the overall health condition of the crop.
 CropType getCropType()
          Gets the type of crop.
 double getGrowingTimeCompleted()
          Gets the amount of growing time completed.
 double getMaxHarvest()
          Gets the maximum possible food harvest for crop.
 java.lang.String getPhase()
          Gets the phase of the crop.
static CropType getRandomCropType()
          Gets a random crop type.
 boolean requiresWork()
          Checks if crop needs additional work on current sol.
 void timePassing(double time)
          Time passing for crop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WASTE_WATER_NEEDED

public static final double WASTE_WATER_NEEDED
See Also:
Constant Field Values

CARBON_DIOXIDE_NEEDED

public static final double CARBON_DIOXIDE_NEEDED
See Also:
Constant Field Values

PLANTING

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

GROWING

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

HARVESTING

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

FINISHED

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

Crop

public Crop(CropType cropType,
            double maxHarvest,
            Farming farm,
            Settlement settlement,
            boolean newCrop)
Constructor

Parameters:
cropType - the type of crop.
maxHarvest - - Maximum possible food harvest for crop. (kg)
farm - - Farm crop being grown in.
settlement - - the settlement the crop is located at.
newCrop - - true if this crop starts in it's planting phase.
Method Detail

getCropType

public CropType getCropType()
Gets the type of crop.

Returns:
crop type

getPhase

public java.lang.String getPhase()
Gets the phase of the crop.

Returns:
phase

getMaxHarvest

public double getMaxHarvest()
Gets the maximum possible food harvest for crop.

Returns:
food harvest (kg.)

getGrowingTimeCompleted

public double getGrowingTimeCompleted()
Gets the amount of growing time completed.

Returns:
growing time (millisols)

requiresWork

public boolean requiresWork()
Checks if crop needs additional work on current sol.

Returns:
true if more work needed.

getCondition

public double getCondition()
Gets the overall health condition of the crop.

Returns:
condition as value from 0 (poor) to 1 (healthy)

addWork

public double addWork(double workTime)
               throws java.lang.Exception
Adds work time to the crops current phase.

Parameters:
workTime - - Work time to be added (millisols)
Returns:
workTime remaining after working on crop (millisols)
Throws:
java.lang.Exception - if error adding work.

timePassing

public void timePassing(double time)
                 throws java.lang.Exception
Time passing for crop.

Parameters:
time - - amount of time passing (millisols)
Throws:
java.lang.Exception - if error during time.

getRandomCropType

public static CropType getRandomCropType()
                                  throws java.lang.Exception
Gets a random crop type.

Returns:
crop type
Throws:
java.lang.Exception - if crops could not be found.

getAverageCropGrowingTime

public static double getAverageCropGrowingTime()
                                        throws java.lang.Exception
Gets the average growing time for a crop.

Returns:
average growing time (millisols)
Throws:
java.lang.Exception - if error reading crop config.