Midterm exam 1 review Fall2005: Turtle Initial
Back to Midterm Exam 1 Review Fall2005
Questions? Answers? Comments?
public class TurtleInitial {
public static void main(String [] args)
{
Picture canvas = new Picture(500,500);
Turtle gooch = new Turtle(canvas);
gooch.turn(90);
gooch.forward(100);
gooch.turn(90);
gooch.forward(100);
gooch.turn(60);
gooch.forward(100);
gooch.turn(60);
gooch.forward(100);
gooch.turn(60);
gooch.forward(200);
gooch.turn(60);
gooch.forward(100);
gooch.turn(60);
gooch.forward(100);
canvas.show();
}
}
I' not sure if you wanted the letters to be curved (the example you gave us was circles/figure eight...), so I did it really simple and just did it in straight lines.
Student159
if anyone has an s as a last name....
public class sTurtle{
public static void main(String [] args){
Picture canvas = new Picture(600,600);
Turtle t = new Turtle(canvas);
t.setPenDown(false);
t.moveTo(450,150);
t.setPenDown(true);
t.turnLeft();
t.forward(150);
t.turnLeft();
t.forward(150);
t.turnLeft();
t.forward(100);
t.turnRight();
t.forward(150);
t.turnRight();
t.forward(150);
canvas.show();
}
}
Removed at KS request
Straight lines are fine. Don't forget that turn() and forward() can take negative numbers, too. Mark Guzdial |
Link to this Page