hypesystem

GC - Ash.java

Oct 19th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.84 KB | None | 0 0
  1. package gc;
  2.  
  3. /**
  4.  * An ash is a kind of tree. It extends the Tree class.
  5.  * @author hypesystem
  6.  */
  7. public class Ash extends Tree {
  8.     private static final double growth = 1.20;
  9.     private static final double start_height = 1.0;
  10.     private static final double max_height = 15;
  11.    
  12.     /**
  13.      * Sets the normal tree specifications (age 1 and height)
  14.      */
  15.     public Ash() {
  16.         age = 1;
  17.         height = start_height;
  18.     }
  19.    
  20.     /**
  21.      * Sets tree specifications with tree having certain age. Used in NewForest.
  22.      * @param age
  23.      */
  24.     public Ash(int age) {
  25.         this.age = age;
  26.         if(start_height * growth * age < max_height)
  27.             height = start_height * growth * age;
  28.         else height = max_height;
  29.     }
  30.    
  31.     /**
  32.      * Overrides the Tree-class growOneYear() method. Makes the tree grow a
  33.      * certain percentage.
  34.      */
  35.     @Override
  36.     public void growOneYear() {
  37.         super.growOneYear();
  38.         if(height < max_height) height *= growth;
  39.     }
  40.    
  41.     /**
  42.      * Overrides the Tree-class growOneYear() method. Makes the tree grow a
  43.      * certain percentage using shadow to caculate hwo much it should grow.
  44.      * Used by NewForest this calculates the amount the tree should grow from
  45.      * the amount of shadow it has.
  46.      * @param shadow the amount of shadow the tree has from 0 - 1.
  47.      */
  48.     @Override
  49.     public void growOneYear(double shadow) {
  50.         super.growOneYear();
  51.         if(height < max_height) height =
  52.                 height * growth - ((height * growth - height) * shadow);
  53.     }
  54.    
  55.     /**
  56.      * Shows the tree's information, adding the name of the tree in front of
  57.      * the standard output of a tree-class item.
  58.      */
  59.     @Override
  60.     public void show() {
  61.         System.out.print("[Ask] ");
  62.         super.show();
  63.     }
  64.    
  65. }
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment