Commit 3b7c58a
Changed files (1)
src
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) {
+ }
+ }
}