@@ -12,46 +12,24 @@ public class StarShow {
1212 Robot robot = new Robot ("batman" );
1313
1414 void makeStars () {
15+ robot .hide ();
16+ robot .moveTo (30 , 550 );
17+ for (int i = 15 ; i < 150 ; i += 10 ) {
18+ drawStar (i );
19+ robot .moveTo (robot .getX () + 15 + i / 2 , robot .getY () - 15 - i / 2 );
20+ robot .setRandomPenColor ();
21+ }
1522
16- drawStar (150 ); //5. delete this line. You will draw the star again in step 8.
17- // 13. Set the speed to 8
18-
19- // 6. Make a variable to hold the X position of the Robot and set it to 10
20-
21- // 7. Make a variable to hold the Y position of the Robot and set it to 600
22-
23- // 8. Make a variable to hold the star size and set it to 25
24-
25- // 12. Use a for loop to repeat steps #19 to #18, 30 times
26-
27- // 19. Set the pen width to i
28-
29- // 10. Set the X position of the robot to your X variable
30-
31- // 11. Set the Y position of the robot to your Y variable
32-
33- // 9. Call the drawStar() method with your star size variable
34-
35- // 14. Increase the value of the X position variable by star size. See Figure 2
36-
37- // 15. decrease the value of the Y position variable by star size. See Figure 3
38-
39- // 16. Increase the star size by 20
40-
41- // 17. Turn the robot 12 degrees
42-
43- // 18. Make each star a different random color like in Figure 4
4423
4524 }
4625
4726 private void drawStar (int starSize ) {
48- // 2. Put the robot's pen down
49-
50- // 4. Repeat both commands 5 times. See Figure 1 at http://bit.ly/star-show
51-
52- // 1. Move the robot the distance of the starSize variable
53-
54- // 3. Turn the robot 144 degrees
27+ robot .penDown ();
28+ robot .setSpeed (500000 );
29+ for (int i = 0 ; i < 5 ; i ++) {
30+ robot .move (starSize );
31+ robot .turn (144 );
32+ }
5533
5634 }
5735
0 commit comments