import java.awt.Color;
import java.util.Enumeration;

public class ThePoPo extends RandomWalker {
	protected boolean inTurn;
	protected Color natural = Color.blue;

	public ThePoPo() {
		//Initializes class
		;
	}

	public Color getColor()
	//Effects: Gets the color for the simulation of the object depending on the
	//natural color of the object and its current action.
	{

		return natural;
	}

	public void executeTurn() throws RuntimeException
	// Note: requires isInitialized is inherited from SimObject
	// EFFECTS: Picks a random direction and tries to move that way.
	//          If the move is successful, return true. If the move fails
	//          because the spot being attempted to move into is already
	//          occupied then return false.

	{
		inTurn = true;

		synchronized (getGrid()) {
			Enumeration neighbors = getNeighbors();
			while (neighbors.hasMoreElements()) {
				SimObject neighbor = (SimObject) neighbors.nextElement();
				if (neighbor instanceof Streaker) {
					//Police kills the streaker
					neighbor.die();
					delay(500);
					getGrid().killObjectAt(
						neighbor.getRow(),
						neighbor.getColumn());
					System.out.println(
						"Oh no! You have been arrested by the PoPo!");
						getGrid().pauseObjects();
					//StreakerSimulator.setVisible();

				}
			}
		}
		super.executeTurn();
		inTurn = false;
	}

} //@nowarn NonNullResult // ESC/Java doesn't know Color constants are not null