/**** * Bees are totally awesome: they always know where they are at any point. * They'll tell you if they're in the NORTH or in the SOUTH half of the board * Justine Sherry * CSE 142 ****/ import java.awt.*; import java.util.*; public class Bee extends Critter { private char location; private Random r; public Bee() { location = '?'; r = new Random(); } // only eats when in the northern half public boolean eat() { return (location == 'N'); } public char getChar() { return location; } public Attack fight(char opponent) { return Attack.SCRATCH; } public Direction getMove() { // because 0 starts at the top, having a smaller // y-coordinate signifies being higher if (getY() < getHeight() / 2) { location = 'N'; } else { location = 'S'; } // "fly" around Direction[] moves = { Direction.NORTH, Direction.SOUTH, Direction.EAST, Direction.WEST }; return moves[r.nextInt(4)]; } public Color getColor() { return Color.YELLOW; } }