diff options
| author | mo khan <mo@mokhan.ca> | 2019-08-05 13:09:44 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2019-08-05 13:09:44 -0600 |
| commit | 3b7c58abefca9db8b1b3431e308fccbe5eeab1e9 (patch) | |
| tree | 4e72daec5f2037490ddd9d277469dead6c4f1123 | |
| parent | 5e81412febd3b27859d6c6deceed5dcc64214f47 (diff) | |
extract sleep method
| -rw-r--r-- | src/Q9/MovingRobot.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/Q9/MovingRobot.java b/src/Q9/MovingRobot.java index 1017d0f..391f407 100644 --- a/src/Q9/MovingRobot.java +++ b/src/Q9/MovingRobot.java @@ -155,10 +155,7 @@ public class MovingRobot extends Robot { clear(); System.out.println(MovingRobot.printGrid(r1, r2)); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } + sleep(1000); } System.out.println("=== Question 9 ==="); @@ -167,7 +164,7 @@ public class MovingRobot extends Robot { System.out.println(String.format("R2 Route: [%s]", r2.printMoves())); } - public static void clear() { + private static void clear() { try { if (System.getProperty("os.name").contains("Windows")) Runtime.getRuntime().exec("cls"); else { @@ -177,4 +174,11 @@ public class MovingRobot extends Robot { } catch (Exception e) { } } + + private static void sleep(int milliseconds) { + try { + Thread.sleep(milliseconds); + } catch (InterruptedException e) { + } + } } |
