

public class DotRace {

   private final static int GOAL = 20;
   private final static int MAX_STEP = 3;

   public static void main(String[] args) {
      Dot redDot = new Dot("RED", MAX_STEP);
      Dot blueDot = new Dot("BLUE", MAX_STEP);

      while (redDot.getPosition() < GOAL && blueDot.getPosition() < GOAL) {
         redDot.step();
         blueDot.step();

         redDot.showPosition();
         blueDot.showPosition();
      }

      if (redDot.getPosition() >= GOAL && blueDot.getPosition() >= GOAL) {
         System.out.println("It is a tie");
      }
      else if (redDot.getPosition() >= GOAL) {
         System.out.println("RED wins!");
      }
      else {
         System.out.println("BLUE wins!");
      }
   }
}
