-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathDangerousTaskDriver.java
More file actions
37 lines (34 loc) · 1.01 KB
/
Copy pathDangerousTaskDriver.java
File metadata and controls
37 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
@Author:
Date:
Teacher: Appel
*/
import kareltherobot.*;
import java.awt.Color;
public class DangerousTaskDriver implements Directions
{
public static void main(String args[]) {
DangerousBot karel = new DangerousBot(5, 5, North, 0);
karel.choosePile();
karel.turnOff();
}
static {
int beepers = (int)(Math.random() * 10); //random beepers on corner Karel currently standing
World.reset();
World.readWorld("worlds/fig6-17.kwld");
World.placeBeepers(5,5,beepers);
if (beepers % 2 == 0) {
World.placeBeepers(5,6,(int)(Math.random() * 50));
World.placeBeepers(5,4, -1);
}
else {
World.placeBeepers(5,6,-1);
World.placeBeepers(5,4, (int)(Math.random() * 50));
}
World.setBeeperColor(Color.black);
World.setStreetColor(Color.gray);
World.setNeutroniumColor(Color.black);
World.setDelay(10);
World.setVisible(true);
}
}