diff options
| author | mo khan <mo@mokhan.ca> | 2019-08-05 14:22:17 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2019-08-05 14:22:17 -0600 |
| commit | 518b6610a9b0e1c0e5c87742136731548eb4fbee (patch) | |
| tree | a38798ae0bf94237f196519caed1cc59fb2160a6 /src/Q9/Robot.java | |
| parent | 68fc0d4e756e48e8cdd02c84f3014db725228b07 (diff) | |
extract constants for sprites
Diffstat (limited to 'src/Q9/Robot.java')
| -rw-r--r-- | src/Q9/Robot.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Q9/Robot.java b/src/Q9/Robot.java index ed0c28c..f3a709a 100644 --- a/src/Q9/Robot.java +++ b/src/Q9/Robot.java @@ -18,6 +18,9 @@ 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 = "1"; + public static final String R2 = "2"; + public static final String COLLISION = "X"; private int x; private int y; @@ -54,9 +57,9 @@ public class Robot { boolean r1InCell = r1.atPosition(row, column); boolean r2InCell = r2.atPosition(row, column); - if (r1InCell && r2InCell) grid += "|X"; - else if (r1InCell) grid += "|1"; - else if (r2InCell) grid += "|2"; + if (r1InCell && r2InCell) grid += "|" + COLLISION; + else if (r1InCell) grid += "|" + R1; + else if (r2InCell) grid += "|" + R2; else grid += "| "; } grid += String.format("|%s", System.lineSeparator()); |
