planty
Class Sprouling

java.lang.Object
  extended by planty.Sprouling

public class Sprouling
extends java.lang.Object

Defines the plant being.

Author:
Nereare

Field Summary
static int BAD
          Plant health constant.
static int DEAD
          Plant health constant.
static int DYING
          Plant health constant.
private static java.lang.String foo
          The class placeholder for not-defined string data.
static int GOOD
          Plant health constant.
static int GREAT
          Plant health constant.
private static java.lang.String[] HEALTH
          The health-status names.
private  int intAge
          The plant\'s age, in days.
private  int intFruitTime
          The amount of time the fruit need to bear a fruit.
private  int intHealth
          The plant\'s health.
private  int intMaxAge
          The maximum age for the plant.
private  int intMaxFruit
          The maximum of fruits the plant can bare.
private  int intMinFruit
          The minimum of fruits the plant can bare.
private  int intWater
          The number of waterings the plant has.
static int MAX_HEALTH
          Maximum health.
static int NEUTRAL
          Plant health constant.
static int PERFECT
          Plant health constant.
private  java.lang.String strDesc
          The plant\'s description -as the creator defines-.
private  java.lang.String strName
          The plant\'s name.
private  java.lang.String strSp
          The plant\'s species.
static int WORST
          Plant health constant.
 
Constructor Summary
Sprouling(java.lang.String name, java.lang.String species, java.lang.String description, int maxFruit, int fruitTime, int maxAge)
          Constructor method.
Sprouling(java.lang.String name, java.lang.String species, java.lang.String description, int minFruit, int maxFruit, int fruitTime, int maxAge)
          Constructor method.
Sprouling(java.lang.String name, java.lang.String species, java.lang.String description, int age, int health, int minFruit, int maxFruit, int fruitTime, int maxAge)
          Constructor method.
 
Method Summary
 void age()
          Adds one day to the plant.
 boolean canAge()
          Checks if the plant can still age up.
 boolean canHeal()
          Checks if the heal() method can be run.
 int getAge()
          Does what you'd expect it to do.
 java.lang.String getDescription()
          Does what you'd expect it to do.
 int getFruitTime()
          Does what you'd expect it to do.
 int getHealth()
          Does what you'd expect it to do.
 java.lang.String getHealth(int health)
          Returns the health name.
 int getMaxAge()
          Does what you'd expect it to do.
 int getMaxFruit()
          Does what you'd expect it to do.
 int getMinFruit()
          Does what you'd expect it to do.
 java.lang.String getName()
          Does what you'd expect it to do.
 java.lang.String getSp()
          Does what you'd expect it to do.
 int getWaterings()
          Does what you'd expect it to do.
 void harm()
          Damages the plant\'s health by one.
 int harvest()
          Gets the number of fruits it'll bear and resets its watering state.
 boolean hasDescription()
          Checks if the plant has a description.
 boolean hasName()
          Checks if the plant has a name.
 boolean hasSp()
          Checks if the plant has a species.
 void heal()
          Heals the plant\'s health by one.
 boolean isAlive()
          Checks if the plant is alive.
 boolean isFruitTime()
          Checks whether it is day for the fruits to be ripe or not.
 boolean isLastDay()
          Checks whether it is the plant's last day of life.
 void kill()
          Set\'s the plants health to zero, hence killing it.
 void renew()
          Returns the plant's state to a neutral (alive, zero-age and so on) state.
 void setAge(int age)
          Does what you'd expect it to do.
 void setDescription(java.lang.String desc)
          Does what you'd expect it to do.
private  void setFruitTime(int fruitTime)
           
 void setHealth(int health)
          Does what you'd expect it to do.
 boolean setHealthBy(int modifier)
          Deprecated. Not working correctly, for now, handle modifiers to health by using setHealth( getHealth() + modifier ).
private  void setMaxAge(int maxAge)
          Does what you'd expect it to do.
private  void setMaxFruit(int maxFruit)
          Does what you'd expect it to do.
private  void setMinFruit(int minFruit)
          Does what you'd expect it to do.
 void setName(java.lang.String name)
          Does what you'd expect it to do.
 void setSp(java.lang.String species)
          Does what you'd expect it to do.
 void setWaterings(int waterings)
          Does what you'd expect it to do.
 boolean wasWatered()
          Checks if the plant was watered at least once.
 void water()
          Water once (adds one to watering count).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

foo

private static final java.lang.String foo
The class placeholder for not-defined string data.

See Also:
Constant Field Values

HEALTH

private static final java.lang.String[] HEALTH
The health-status names.


DEAD

public static final int DEAD
Plant health constant.

See Also:
Constant Field Values

DYING

public static final int DYING
Plant health constant.

See Also:
Constant Field Values

WORST

public static final int WORST
Plant health constant.

See Also:
Constant Field Values

BAD

public static final int BAD
Plant health constant.

See Also:
Constant Field Values

NEUTRAL

public static final int NEUTRAL
Plant health constant.

See Also:
Constant Field Values

GOOD

public static final int GOOD
Plant health constant.

See Also:
Constant Field Values

GREAT

public static final int GREAT
Plant health constant.

See Also:
Constant Field Values

PERFECT

public static final int PERFECT
Plant health constant.

See Also:
Constant Field Values

MAX_HEALTH

public static final int MAX_HEALTH
Maximum health.

See Also:
Constant Field Values

strName

private java.lang.String strName
The plant\'s name.


strSp

private java.lang.String strSp
The plant\'s species.


strDesc

private java.lang.String strDesc
The plant\'s description -as the creator defines-.


intAge

private int intAge
The plant\'s age, in days.


intHealth

private int intHealth
The plant\'s health.
It can\'t reach zero!


intMinFruit

private int intMinFruit
The minimum of fruits the plant can bare.


intMaxFruit

private int intMaxFruit
The maximum of fruits the plant can bare.


intMaxAge

private int intMaxAge
The maximum age for the plant.


intFruitTime

private int intFruitTime
The amount of time the fruit need to bear a fruit.


intWater

private int intWater
The number of waterings the plant has.

Constructor Detail

Sprouling

public Sprouling(java.lang.String name,
                 java.lang.String species,
                 java.lang.String description,
                 int maxFruit,
                 int fruitTime,
                 int maxAge)
Constructor method.

Parameters:
name - guess what?
species - guess what?
description - guess what?
maxFruit - the maximum of fruits this plant will be able to bear, given the minimun as zero.
fruitTime - the number of days between one frutification and the next.
maxAge - the maximum age, given it's starting at age zero (days).

Sprouling

public Sprouling(java.lang.String name,
                 java.lang.String species,
                 java.lang.String description,
                 int minFruit,
                 int maxFruit,
                 int fruitTime,
                 int maxAge)
Constructor method.

Parameters:
name - guess what?
species - guess what?
description - guess what?
minFruit - the minimum of fruits this plant will be able to bear.
maxFruit - the maximum of fruits this plant will be able to bear.
fruitTime - the number of days between one frutification and the next.
maxAge - the maximum age for this plant, given it's starting at age zero (days).

Sprouling

public Sprouling(java.lang.String name,
                 java.lang.String species,
                 java.lang.String description,
                 int age,
                 int health,
                 int minFruit,
                 int maxFruit,
                 int fruitTime,
                 int maxAge)
Constructor method.

Parameters:
name - guess what?
species - guess what?
description - guess what?
age - the starting age.
health - the starting health.
minFruit - the minimum of fruits this plant will be able to bear.
maxFruit - the maximum of fruits this plant will be able to bear.
fruitTime - the number of days between one frutification and the next.
maxAge - the maximum age.
Method Detail

getName

public java.lang.String getName()
Does what you'd expect it to do.

Returns:
the plant's name.

getSp

public java.lang.String getSp()
Does what you'd expect it to do.

Returns:
the plant's species.

getDescription

public java.lang.String getDescription()
Does what you'd expect it to do.

Returns:
the plant's description.

getAge

public int getAge()
Does what you'd expect it to do.

Returns:
the plant's age.

getHealth

public int getHealth()
Does what you'd expect it to do.

Returns:
the plant's health.

getHealth

public java.lang.String getHealth(int health)
Returns the health name.

Parameters:
health - the health number.
Returns:
the health name, by the given health number;

getMinFruit

public int getMinFruit()
Does what you'd expect it to do.

Returns:
the plant's minimum of fruits.

getMaxFruit

public int getMaxFruit()
Does what you'd expect it to do.

Returns:
the plant's maximum of fruits.

getFruitTime

public int getFruitTime()
Does what you'd expect it to do.

Returns:
the plant's time to bear fruits.

getMaxAge

public int getMaxAge()
Does what you'd expect it to do.

Returns:
the plant's maximum age.

getWaterings

public int getWaterings()
Does what you'd expect it to do.

Returns:
the plant's number of waterings.

harvest

public int harvest()
Gets the number of fruits it'll bear and resets its watering state.

Returns:
the number of fruits it'll bear, zero if the plant is dead or -1 if it the fruits are not ripe. *LoL*

hasName

public boolean hasName()
Checks if the plant has a name.

Returns:
true if it has one, false otherwise.

hasSp

public boolean hasSp()
Checks if the plant has a species.

Returns:
true if it has one, false otherwise.

hasDescription

public boolean hasDescription()
Checks if the plant has a description.

Returns:
true if it has one, false otherwise.

isAlive

public boolean isAlive()
Checks if the plant is alive.

Returns:
true if it is, false otherwise.

isFruitTime

public boolean isFruitTime()
Checks whether it is day for the fruits to be ripe or not.

Returns:
true if it is day, false otherwise.

canAge

public boolean canAge()
Checks if the plant can still age up.

Returns:
true if it can, false otherwise.

canHeal

public boolean canHeal()
Checks if the heal() method can be run.

Returns:
true if the health is beneath the maximum, false false otherwise.

wasWatered

public boolean wasWatered()
Checks if the plant was watered at least once.

Returns:
true if it was, false otherwise.

isLastDay

public boolean isLastDay()
Checks whether it is the plant's last day of life.

Returns:
true if it is, false otherwise.

setName

public void setName(java.lang.String name)
Does what you'd expect it to do.

Parameters:
name - the new name.

setSp

public void setSp(java.lang.String species)
Does what you'd expect it to do.

Parameters:
species - the new species.

setDescription

public void setDescription(java.lang.String desc)
Does what you'd expect it to do.

Parameters:
desc - the new description.

setAge

public void setAge(int age)
Does what you'd expect it to do.

Parameters:
age - the new age.

age

public void age()
Adds one day to the plant.


setHealth

public void setHealth(int health)
Does what you'd expect it to do.

Parameters:
health - the new health.

setHealthBy

public boolean setHealthBy(int modifier)
Deprecated. Not working correctly, for now, handle modifiers to health by using setHealth( getHealth() + modifier ).

Sums the given amount to the plant's health, as long as the resulting value is possible.

Parameters:
modifier - any integer number.
Returns:
true if the sum was possible and made, false otherwise.

heal

public void heal()
Heals the plant\'s health by one.


harm

public void harm()
Damages the plant\'s health by one.


kill

public void kill()
Set\'s the plants health to zero, hence killing it.


setMinFruit

private void setMinFruit(int minFruit)
Does what you'd expect it to do.

Parameters:
minFruit - new minimum of fruits.

setMaxFruit

private void setMaxFruit(int maxFruit)
Does what you'd expect it to do.

Parameters:
maxFruit - new maximum of fruits.

setFruitTime

private void setFruitTime(int fruitTime)

setMaxAge

private void setMaxAge(int maxAge)
Does what you'd expect it to do.

Parameters:
maxAge - new maximum age.

setWaterings

public void setWaterings(int waterings)
Does what you'd expect it to do.

Parameters:
waterings - new number of waterings.

water

public void water()
Water once (adds one to watering count).


renew

public void renew()
Returns the plant's state to a neutral (alive, zero-age and so on) state.