-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFourSquare.java
More file actions
46 lines (28 loc) · 762 Bytes
/
Copy pathFourSquare.java
File metadata and controls
46 lines (28 loc) · 762 Bytes
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
38
39
40
41
42
import javax.swing.JOptionPane;
import org.jointheleague.graphical.robot.Robot;
public class FourSquare {
// 2. Create a new Robot
Robot Squarebot = new Robot();
void go() {
// 4. Make the robot move as fast as possible
Squarebot.setSpeed(10);
// 5. Set the pen width to 5
// 6. Do steps #7 to #8 four times...
// 7. Set the pen color to random
// 1. Call the drawSquare() method
drawSquare();
// 8. Turn the robot 90 degrees to the right
}
/* 3. Fill in the code to draw a square inside the method below. */
void drawSquare ()
{
for (int i = 0; i < 4; i++) {
Squarebot.penDown();
Squarebot.move(240);
Squarebot.setRandomPenColor();
}
}
public static void main(String[] args) {
new FourSquare().go();
}
}