import java.awt.*;

/** The Follower class is a type of Sprite that follows a Path.  Each
    time a Follower is asked to step, it sets its location to the next
    Point in its Path .
*/
public class Follower extends Sprite {

  private Path path;

  /** Constructor to display Image img along Path p.
    */
  public Follower(String name, Image img, Path p) {
    super(name, img);
    this.path = p;
  }
  
  /** Step method.
      effects: sets location of follower to the next Point in
               this.path
  */
  public void step() {
    Point p = path.nextPoint();
    int x = p.getX() - getWidth()/2;
    int y = p.getY() - getHeight()/2;
    setLocation(new Point(x,y));
  }
  
  /** Sprite tick method.
      @see Sprite#tick
  */
  public void tick() {
    step();
  }

}
