Skunk
errors
The following critter
(
Skunk.java
)
is an attempt to make a critter that goes W, W, N and repeats, unless he eats food, in which case he will start going W, W, S.
But the file contains errors.
Download it and fix the errors so it compiles/runs properly.
Test it in
CritterMain
and Practice-It.
public class Skunk extend Critter { private int moves; private boolean hungry; public void Skunk() { // constructor hungry = false; } public static boolean eat() { hungry = true; return true; } public Direction getmoves() { moves++; if (moves >= 3) { moves = 0; } if (moves == 1 && moves == 2) { return Direction.WEST; } else if (hungry) { return Direction.NORTH; } else if (!hungry) { return Direction.SOUTH; } } }