Midterm exam 1 review Fall2006: Make Turtle Boxes
Back to Midterm Exam 1 Review Fall2006
Questions? Answers? Comments?
public class TurtleBoxInBox
{
public static void main(String[]Args)
{
Picture canvas = new Picture(500,500);
Turtle craig = new Turtle(canvas);
for(int i = 0;i < 4;i++)
{
craig.forward(200);
craig.turn(90);
}
craig.penUp();
craig.forward(50);
craig.turn(90);
craig.forward(50);
craig.turn(270);
craig.penDown();
for(int i = 0;i < 4;i++)
{
craig.forward(100);
craig.turn(90);
}
canvas.show();
}
}
//REMOVED Cormack
//I changed it around a little bit from the original code here so that the larger box
//Started in the very middle of the picture
public class TurtleBoxInBox
{
public static void main(String[]Args)
{
Picture canvas = new Picture(500,500);
Turtle smallone = new Turtle(canvas);
for(int i = 0;i 4;i++)
{
smallone.forward(100);
smallone.turn(90);
}
smallone.penUp();
smallone.turn(-135);
smallone.forward(10(5^(1/2))); // Is this correct syntax, does ^ stand for raise to the power to? or does it stand for something else?
smallone.turn(135);
smallone.penDown();
for(int i = 0;i 4;i++)
{
smallone.forward(200);
smallone.turn(90);
}
canvas.show();
}
}
//chris ang, another version, not as accurate as the first, but jsut trying!
Link to this Page