forked from League-Archive/IntroToJavaWorkshop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPentagonCrazy.java
More file actions
executable file
·44 lines (26 loc) · 1.29 KB
/
PentagonCrazy.java
File metadata and controls
executable file
·44 lines (26 loc) · 1.29 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
38
39
40
41
42
43
44
package section2;
import java.awt.Color;
import org.jointheleague.graphical.robot.Robot;
/* Teacher’s note: before beginning, draw a pentagon and have students work out the angle that the robot will have to turn (360/5) */
public class PentagonCrazy {
private void makePrettyThings() {
// 1. Create a new Robot
// 3. Put the robot's pen down
// 8. Make the robot go at maximum speed (100)
// 9. Set the pen to a color that you like for the shape
// 4. Make a variable for the number of sides you want (can’t test this one)
// 5. Make a second variable for the angle you want the robot to turn. Hint: you can divide in Java using "/". Can’t test until step 6
// 7. Use a for loop to repeat the steps below (#2, #10, #6, #11) 200 times. When this is done you should see a pentagon
// 2. Move the robot 200 pixels
// 10. Change the previous line of code to make the robot move "i" pixels instead of 200
// 6. Turn the robot the amount in your angle variable
// 11. Turn the robot one more degree
}
// Variations:
// *12. make the pattern really huge
// *13. randomize the color of the pattern
// *14. experiment with different shapes
public static void main(String[] args) {
new PentagonCrazy().makePrettyThings();
}
}