com.collegeboard.gridworld.actor
Class Alien

java.lang.Object
  extended by com.collegeboard.gridworld.actor.Actor
      extended by com.collegeboard.gridworld.actor.Alien

public class Alien
extends Actor

An alien is an actor that can move and turn. It drops flowers as it moves. Override an alien to draw shapes in the actor world.

copyright© 2005 Cay S. Horstmann (http://horstmann.com)

Author:
Cay Horstmann

Constructor Summary
Alien()
          Constructs a green alien.
Alien(Color color)
          Constructs an alien of a given color.
 
Method Summary
 void act()
          Override this method to define the action of this actor.
 boolean canMove()
          Tests whether this alien can move forward.
 void move()
           
 void turn()
          Makes this alien turn by 45 degrees to the right.
 
Methods inherited from class com.collegeboard.gridworld.actor.Actor
getColor, getDirection, getGrid, getLocation, moveTo, putSelfInGrid, removeSelfFromGrid, setColor, toString, turnBy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Alien

public Alien()
Constructs a green alien.


Alien

public Alien(Color color)
Constructs an alien of a given color.

Parameters:
color - the color for this alien
Method Detail

act

public void act()
Description copied from class: Actor
Override this method to define the action of this actor.

Specified by:
act in class Actor

turn

public void turn()
Makes this alien turn by 45 degrees to the right.


move

public void move()

canMove

public boolean canMove()
Tests whether this alien can move forward. The alien must be in a grid, the next forward location must be valid, and it must either be empty or occupied by a flower.

Returns:
true if this alien can move.