import java.awt.*; /* *---------------------------------------------------------------------- * * Tree.java */ /** The only thing that distinguish Trees from Obstacles is that Trees has a sign attribute which is used to decide in which direction to deflect bullets. */ /* *---------------------------------------------------------------------- */ public class Tree extends Obstacle { private float sign; /* *---------------------------------------------------------------------- * * Tree */ /** @param t texture with which the tree is drawn. @param x x-coordinate @param y y-coordinate @param p the border of the tree. */ /* *---------------------------------------------------------------------- */ public Tree(Image t, int x, int y, Polygon p) { super(t, x, y, p); if((float)Math.random() > 0.5) { sign = 1; } else { sign = -1; } } /* *---------------------------------------------------------------------- * * getSign */ /** @return +1 or -1, which is decided in the constructor. */ /* *---------------------------------------------------------------------- */ public float getSign() { return sign; } }