Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package gc;
- /**
- * A beech is a kind of tree. It extends the Tree class.
- * @author hypesystem
- */
- public class Beech extends Tree {
- private static final double growth = 1.06;
- private static final double start_height = 0.5;
- private static final int max_growth_age = 65;
- /**
- * Sets the normal tree specifications (age 1 and height)
- */
- public Beech() {
- age = 1;
- height = start_height;
- }
- /**
- * Sets tree specifications with tree having certain age. Used in NewForest.
- * @param age
- */
- public Beech (int age) {
- this.age = age;
- if(age < max_growth_age) height = start_height * growth * age;
- else height = start_height * growth * max_growth_age;
- }
- /**
- * Overrides the Tree-class growOneYear() method. Makes the tree grow a
- * certain percentage.
- */
- @Override
- public void growOneYear() {
- super.growOneYear();
- if(age < max_growth_age) height *= growth;
- }
- /**
- * Overrides the Tree-class growOneYear() method. Makes the tree grow a
- * certain percentage using shadow to caculate hwo much it should grow.
- * Used by NewForest this calculates the amount the tree should grow from
- * the amount of shadow it has.
- * @param shadow the amount of shadow the tree has from 0 - 1.
- */
- @Override
- public void growOneYear(double shadow) {
- super.growOneYear();
- if(age < max_growth_age) height =
- height * growth - ((height * growth - height) * shadow);
- }
- /**
- * Shows the tree's information, adding the name of the tree in front of
- * the standard output of a tree-class item.
- */
- @Override
- public void show() {
- System.out.print("[Bøg] ");
- super.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment