hypesystem

GC - Tree.java

Oct 19th, 2011
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. package gc;
  2.  
  3. /**
  4.  * A tree is what grows in a forest. This is a superclass, making it possible to
  5.  * have several types of trees under this.
  6.  * @author hypesystem
  7.  */
  8. public class Tree {
  9.     protected int age;
  10.     protected double height;
  11.    
  12.     /**
  13.      * Makes the tree grow one year.
  14.      */
  15.     public void growOneYear() {
  16.         age++;
  17.     }
  18.    
  19.     public void growOneYear(double shadow) {
  20.         growOneYear();
  21.     }
  22.    
  23.     /**
  24.      * Gets the height of the tree
  25.      * @return height of tree
  26.      */
  27.     public double getHeight() {
  28.         return height;
  29.     }
  30.    
  31.     /**
  32.      * Shows the information of the tree (age and height).
  33.      */
  34.     public void show() {
  35.         System.out.print("Alder "+age+" | Højde "+getHeight()+"\n");
  36.     }
  37.    
  38. }
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment