Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
*.class

*.class

*.class

*.class
4 changes: 3 additions & 1 deletion src/solutions/PentagonCrazySolution.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package solutions;

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) */
Expand All @@ -14,7 +16,7 @@ private void makePrettyThings() {
// 8. make the robot go at maximum speed
robot.setSpeed(10);
// 9. choose a color that you like for the shape
robot.setPenColor(30, 130, 30);
robot.setPenColor(Color.GREEN);
// 4. make a variable for the number of sides you want (can’t test this one)
int sides = 5;
// 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
package solutions;
import java.util.Random;

import org.jointheleague.graphical.robot.Robot;

public class DavesSpiralSolution {
public class SpiralSolution {

public static void main(String[] args) {
// 1. Create a new Robot and set its pen to the down position
Robot rob = new Robot();
rob.penDown();
Robot robot = new Robot();
robot.penDown();
// 3. Set the robot to go as fast as possible
rob.setSpeed(10);
robot.setSpeed(10);
// 4. Do the following (steps 5-8) 75 times
for(int i = 0; i < 75; i++)
{
// 6. Change the pen color to random
rob.setPenColor(new Random().nextInt(255), new Random().nextInt(255), new Random().nextInt(255));
robot.setRandomPenColor();
// 5. Move the robot 5 times the current line number you are drawing (5*i)
rob.move(5*i);
robot.move(5*i);
// 2. Turn the robot 1/3 of 360 degrees to the right
//rob.turn(360 / 3);
// 7. Change the number of sides to 7 (don’t add a new line of code for this one!)
rob.turn(360 / 7);
robot.turn(360 / 7);
// 8. Set the pen width to i
rob.setPenWidth(i);
robot.setPenWidth(i);
}
}
}