World w = new World(); Turtle t = new Turtle (w); int count; //draw outer red square t.setPenColor (Color.RED); count = 0; while ( count < 4 ) { t.forward (100); t.turn (90); count = count + 1; } // move to in square location t.penUp (); t.forward (25); t.turn (90); t.forward (25); t.turn (270); t.penDown (); // draw inner blue square t.setPenColor (Color.BLUE); count = 0; while ( count < 4 ) { t.forward (50); t.turn (90); count = count + 1; } // show the drawing w.show ();
public static void q22 (Turtle t, int len, Color c) { Color temp = t.getPenColor(); t.setPenColor (c); int count = 0; while (count < 9) { t.forward (len); t.turn (720/9); // this value is 80 degrees count = count + 1; } t.setPenColor (temp); }