diff options
| author | mo khan <mo@mokhan.ca> | 2019-08-05 13:08:05 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2019-08-05 13:08:05 -0600 |
| commit | 5e81412febd3b27859d6c6deceed5dcc64214f47 (patch) | |
| tree | ed8ee6b56d2965d24bccdd1cd8b6666f0693d009 /src | |
| parent | 3cfbf44444b8ba08ed75d7c317bcf543f3ded10f (diff) | |
make clear work on posix and add sleep
Diffstat (limited to 'src')
| -rw-r--r-- | src/Q9/MovingRobot.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/Q9/MovingRobot.java b/src/Q9/MovingRobot.java index 752a5d8..1017d0f 100644 --- a/src/Q9/MovingRobot.java +++ b/src/Q9/MovingRobot.java @@ -155,6 +155,10 @@ public class MovingRobot extends Robot { clear(); System.out.println(MovingRobot.printGrid(r1, r2)); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } } System.out.println("=== Question 9 ==="); @@ -163,10 +167,13 @@ public class MovingRobot extends Robot { System.out.println(String.format("R2 Route: [%s]", r2.printMoves())); } - public static final void clear() { + public static void clear() { try { if (System.getProperty("os.name").contains("Windows")) Runtime.getRuntime().exec("cls"); - else Runtime.getRuntime().exec("clear"); + else { + System.out.print("\033[H\033[2J"); + System.out.flush(); + } } catch (Exception e) { } } |
