Commit 092ccd8

mo khan <mo@mokhan.ca>
2019-08-05 20:38:57
extract separator constant
1 parent 3f52069
Changed files (1)
src/Q9/Robot.java
@@ -18,10 +18,11 @@ public class Robot {
   public static final int SOUTH_WEST = LEFT_DOWN_CORNER;
   public static final int WEST = LEFT;
   public static final int NORTH_WEST = LEFT_UP_CORNER;
-  public static final String R1 = "๐Ÿค–";
-  public static final String R2 = "๐Ÿš€";
-  public static final String COLLISION = "๐Ÿ”ฅ";
-  public static final String SPACE = "โ€";
+  public static final String R1 = "1";
+  public static final String R2 = "2";
+  public static final String COLLISION = "X";
+  public static final String SPACE = " ";
+  public static final String SEPARATOR = "|";
 
   private int x;
   private int y;
@@ -53,17 +54,19 @@ public class Robot {
 
   public static String printGrid(Robot r1, Robot r2) {
     String grid = "";
+
     for (int row = 0; row < 10; row++) {
       for (int column = 0; column < 10; column++) {
         boolean r1InCell = r1.atPosition(row, column);
         boolean r2InCell = r2.atPosition(row, column);
 
-        if (r1InCell && r2InCell) grid += "|" + COLLISION;
-        else if (r1InCell) grid += "|" + R1;
-        else if (r2InCell) grid += "|" + R2;
-        else grid += "|" + SPACE;
+        grid += SEPARATOR;
+        if (r1InCell && r2InCell) grid += COLLISION;
+        else if (r1InCell) grid += R1;
+        else if (r2InCell) grid += R2;
+        else grid += SPACE;
       }
-      grid += String.format("|%s", System.lineSeparator());
+      grid += String.format("%s%s", SEPARATOR, System.lineSeparator());
     }
     return grid;
   }