|
1 | 1 | package solutions; |
2 | 2 |
|
| 3 | +import java.awt.Color; |
| 4 | + |
3 | 5 | import org.jointheleague.graphical.robot.Robot; |
4 | 6 |
|
5 | 7 | /* Teacher’s note: before beginning, draw a pentagon and have students work out the angle that the robot will have to turn (360/5) */ |
6 | 8 |
|
7 | 9 | public class PentagonCrazySolution { |
8 | 10 |
|
9 | 11 | private void makePrettyThings() { |
10 | | - // 1. create a new Robot |
| 12 | + // 1. Create a new Robot |
11 | 13 | Robot robot = new Robot(); |
12 | 14 | // 3. Put the robot's pen down |
13 | 15 | robot.penDown(); |
14 | | - // 8. make the robot go at maximum speed |
| 16 | + // 8. Make the robot go at maximum speed (10) |
15 | 17 | robot.setSpeed(10); |
16 | | - // 9. choose a color that you like for the shape |
17 | | - robot.setPenColor(30, 130, 30); |
18 | | - // 4. make a variable for the number of sides you want (can’t test this one) |
| 18 | + // 9. Set the pen to a color that you like for the shape |
| 19 | + robot.setPenColor(Color.CYAN); |
| 20 | + // 4. Make a variable for the number of sides you want (can’t test this one) |
19 | 21 | int sides = 5; |
20 | | - // 5. make a variable for the angle you want the robot to turn. Hint: you can divide in Java using “/”. Can’t test until step 6. |
| 22 | + // 5. Make a variable for the angle you want the robot to turn. Hint: you can divide in Java using "/". Can’t test until step 6. |
21 | 23 | int angle = 360 / sides; |
22 | | - // 7. Do everything below 200 times. When this is done you will see a pentagon. |
| 24 | + // 7. Do everything below 200 times. When this is done you should see a pentagon. |
23 | 25 | for (int i = 0; i < 200; i++) { |
24 | 26 | // 2. Move the robot 200 pixels |
25 | 27 | // robot.move(200); |
26 | | - // 9. make the robot move "i" pixels instead of 200 (don’t need new line of code for this, just change previous one) |
| 28 | + // 9. Make the robot move "i" pixels instead of 200 (don’t need new line of code for this, just change previous one) |
27 | 29 | robot.move(i); |
28 | | - // 6. turn the robot the amount in your angle variable |
| 30 | + // 6. Turn the robot the amount in your angle variable |
29 | 31 | robot.turn(angle); |
30 | | - // 10. turn the robot one more degree |
| 32 | + // 10. Turn the robot one more degree |
31 | 33 | robot.turn(1); |
32 | 34 | } |
33 | | - |
34 | 35 | } |
35 | 36 |
|
36 | 37 | // Variations: |
|
0 commit comments