/**
 * Simulates a colored dot for a dot race.
 *   @author Dave Reed
 *   @version 8/25/08
 *
 */
public class Dot {

	private Die die;
	private String dotColor;
	private int dotPosition;
	
        /**
         * constructs a Dot object of the specified color and step
         *   @param color the color of the dot (e.g., "BLUE")
         *   @param maxStep the maximum distance of any single step
         */
	public Dot(String color, int maxStep) {
	    this.die = new Die(maxStep);
	    this.dotColor = color;
	    this.dotPosition= 0;
	}

        /**
         * accessor method to get the dot's position
         *   @return the position (i.e., number of steps from start)
         */
	public int getPosition() {
	    return this.dotPosition;
	}
	
        /**
         * performs one step, moving the dot ahead a random amount
         */
	public void step() {
	    this.dotPosition += this.die.roll();
	}
	
        /**
         * resets the dot back to the start
         */
        public void reset() {
	    this.dotPosition = 0;
	}
	
        /**
         * prints the current position of the dot
         */
        public void showPosition() {
	    System.out.println(this.dotColor + ": " + 
	                       this.dotPosition);
	}
}
