public class Dot {
    private static final int CIRCLE_SIZE = 40;
    private static final int START_LINE = -200;
    
    private Die die;
    private Circle visualDot;
	private String dotColor;
	private int dotPosition;
	private int moveDistance;
	private static int nextAvailableLane = 1;
	
	public Dot(String color, int maxStep) {
	    int lane = Dot.nextAvailableLane;
	    Dot.nextAvailableLane++;
	    
	    this.die = new Die(maxStep);

	    this.visualDot = new Circle();
	    this.visualDot.changeSize(Dot.CIRCLE_SIZE);
	    this.visualDot.changeColor(color);
	    this.visualDot.moveHorizontal(Dot.START_LINE);
	    this.visualDot.moveVertical(Dot.CIRCLE_SIZE*(lane-1));
	    this.dotColor = color;
	    this.dotPosition= 0;
	    this.moveDistance = 0;
	}

	public void step() {
	    int dist = this.die.roll();
	    this.dotPosition += dist;
	    this.moveDistance += dist;
	   }
	
	public void reset() {
	    this.visualDot.moveHorizontal(-this.dotPosition);
	    this.dotPosition = 0;
	    this.moveDistance = 0;
	}
	
	public int getPosition() {
	    return this.dotPosition;
	}
		
	public void showPosition() {
	    //System.out.println(this.dotColor + ": " +
        //                   this.dotPosition);
        this.visualDot.makeVisible();
        this.visualDot.moveHorizontal(this.moveDistance);
        this.moveDistance = 0;
	}
}
