Commit 3b7c58a

mo khan <mo@mokhan.ca>
2019-08-05 19:09:44
extract sleep method
1 parent 5e81412
Changed files (1)
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) {
+    }
+  }
 }