hypesystem

GC - Beech.java

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