summaryrefslogtreecommitdiff
path: root/src/Q9/MovingRobot.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Q9/MovingRobot.java')
-rw-r--r--src/Q9/MovingRobot.java14
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) {
+ }
+ }
}