/**
 * Turtle.java
 * @author Johannes Martin
 * @version 1.0
 */
import java.awt.*;

/** 
 * Class Turtle simulates a turtle walking on a drawing canvas.
 * As the turtle walks it leaves something behind...
 */
public class Turtle {
  Graphics graphics; // the graphics handle of the drawing canvas
  int xPosition;     // the current horizontal Position
  int yPosition;     // the current vertical Position

  /**
   * Create a new Turtle.
   *
   * @param graphics graphics context to draw on
   * @param xOrigin initial horizontal position of the turtle
   * @param yOrigin initial vertical position of the turtle
   */
  public Turtle(Graphics graphics, int xOrigin, int yOrigin) {
    this.graphics = graphics;
    xPosition = xOrigin;
    yPosition = yOrigin;
  }

  /**
   * Move the turtle on the canvas.
   *
   * @param number of pixels by which to move the turtle horizontally
   * @param number of pixels by which to move the turtle vertically
   */
  public void move(int xOffset, int yOffset) {
    int newX = xPosition + xOffset;
    int newY = yPosition + yOffset;
    
    graphics.drawLine(xPosition, yPosition, newX, newY);
    xPosition = newX;
    yPosition = newY;
  }
}
