diff options
| author | mo khan <mo@mokhan.ca> | 2019-08-05 14:04:26 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2019-08-05 14:04:26 -0600 |
| commit | 223504b53a19484e39ee5256fb83ff0bf3e0ba7f (patch) | |
| tree | 6cb7b03003813fb921f9f0760dc08ffd5c331a60 /src/Q9/Robot.java | |
| parent | 8f840e93331045454f8a21ab1d04ed7e338144d7 (diff) | |
extract variables to check if robots in cell
Diffstat (limited to 'src/Q9/Robot.java')
| -rw-r--r-- | src/Q9/Robot.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Q9/Robot.java b/src/Q9/Robot.java index 89165eb..638b581 100644 --- a/src/Q9/Robot.java +++ b/src/Q9/Robot.java @@ -51,8 +51,11 @@ public class Robot { String grid = ""; for (int row = 0; row < 10; row++) { for (int column = 0; column < 10; column++) { - if (r1.atPosition(row, column)) grid += "|1"; - else if (r2.atPosition(row, column)) grid += "|2"; + boolean r1InCell = r1.atPosition(row, column); + boolean r2InCell = r2.atPosition(row, column); + + if (r1InCell) grid += "|1"; + else if (r2InCell) grid += "|2"; else grid += "| "; } grid += String.format("|%s", System.lineSeparator()); |
