
/**
 * A class that models a simple Dot from a dot race.
 * 
 * @author Dave Reed
 * @version 1/30/13
 */
public class Dot {
    private Die die;
    private String dotColor;
    private int dotPosition;
    private Circle dotImage;
      
    private static int nextAvailable = 1;
    private int dotNumber;
    
    private static int dotSize = 60;
    	
    public Dot(String color, int maxStep) {
    	this.die = new Die(maxStep);
    	this.dotColor = color;
    	this.dotPosition= 0;
        this.dotImage = new Circle();
        this.dotImage.changeColor(color);
        this.dotImage.changeSize(Dot.dotSize);
        
        this.dotNumber = Dot.nextAvailable;
        Dot.nextAvailable++;
    }

    /**
     * Simulates a single step of the Dot, moving it forward a random amount.
     */
    public void step() {
    	this.dotPosition += this.die.roll();
    }
    
    /**
     * Resets the position of the Dot back to 0.
     */
    public void reset() {
        this.dotPosition = 0;
    }
    
    /**
     * Acessor method that determines the current position of the Dot.
     *   @return the Dot's position
     */
    public int getPosition() {
    	return this.dotPosition;
    }
    
    /**
     * Displays the color and current position of the Dot.
     */
    
    public void showPosition() {
        this.dotImage.moveTo(this.dotPosition, Dot.dotSize*(this.dotNumber-1));
        this.dotImage.makeVisible();
    }
}
