barsuift.simLife.tree
Class BasicTreeLeaf

java.lang.Object
  extended by java.util.Observable
      extended by barsuift.simLife.tree.BasicTreeLeaf
All Implemented Interfaces:
IObservable, LivingPart, TreeLeaf

public class BasicTreeLeaf
extends java.util.Observable
implements TreeLeaf


Constructor Summary
BasicTreeLeaf(Universe universe, TreeLeafState leafState)
           
 
Method Summary
 java.math.BigDecimal collectFreeEnergy()
           
 boolean equals(java.lang.Object obj)
           
 int getAge()
           
 Percent getEfficiency()
           
 java.math.BigDecimal getEnergy()
           
 java.lang.Long getId()
           
 TreeLeafState getState()
           
 TreeLeaf3D getTreeLeaf3D()
           
 int hashCode()
           
 boolean isTooWeak()
          Return true if the leaf efficiency is lower than the lowest acceptable value
 void spendTime()
          Make the leaf older than it was.
 java.lang.String toString()
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface barsuift.simLife.IObservable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 

Constructor Detail

BasicTreeLeaf

public BasicTreeLeaf(Universe universe,
                     TreeLeafState leafState)
Method Detail

getId

public java.lang.Long getId()
Specified by:
getId in interface LivingPart

spendTime

public void spendTime()
Make the leaf older than it was.

Concretely, it means :

  1. age : reduce the efficiency by 5 percent and send a notifying message of LeafUpdateCode.age
  2. collect solar energy : add energy based on sun luminosity and leaf efficiency
  3. if the leaf is too weak :
    • fall : send a notifying message of LeafUpdateCode.fall
    else :
    • use energy : improve the leaf efficiency by using the collected energy

Specified by:
spendTime in interface LivingPart

isTooWeak

public boolean isTooWeak()
Return true if the leaf efficiency is lower than the lowest acceptable value

Specified by:
isTooWeak in interface TreeLeaf

getEfficiency

public Percent getEfficiency()
Specified by:
getEfficiency in interface TreeLeaf

getEnergy

public java.math.BigDecimal getEnergy()
Specified by:
getEnergy in interface TreeLeaf

collectFreeEnergy

public java.math.BigDecimal collectFreeEnergy()
Specified by:
collectFreeEnergy in interface TreeLeaf

getAge

public int getAge()
Specified by:
getAge in interface LivingPart

getTreeLeaf3D

public TreeLeaf3D getTreeLeaf3D()
Specified by:
getTreeLeaf3D in interface TreeLeaf

getState

public TreeLeafState getState()
Specified by:
getState in interface TreeLeaf

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2010. All Rights Reserved.