Start Here

Media Resources

File Conversion

Turtle Geometry

All the following exercises are intended to be implemented in the Greenfoot scenario "turtle-v4". Download the scenario here and open it in Greenfoot before continuing.

Preparation for Pair Programming

This video shows you some cool stuff you can do with the act method. The design ideas in the video are from the book Turtle Geometry

After you've opened the turtle-v4 scenario, follow along with the video.

A Square Design

Open up the editor for the Turtle class. You can do this by double-clicking on the Turtle class in the "Actor classes" area of Greenfoot, or right-click (or control-click) on the Turtle class and select "Open editor".

Change your act method so that it calls a method to draw a square and then turns some amount.

When you've created a design you like, save it as "square-design-1"

Poly Designs

Try calling the poly method from inside the act, like this:

    /**
     * Act - do whatever the Turtle wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        this.poly(100, 72);
    }    

Here are some other poly calls to try:

  • this.poly(200, 144);
  • this.poly(100, 60);
  • this.poly(200, 135);
  • this.poly(200, 108);

Try calling poly with some other arguments. If you find a design you like, you might want to save it to a PNG file with a name that includes the arguments you used. For example, if you like the design made by this.poly(200, 144), you could write the image to a file called poly-200-144.png.

What happens if you try this.poly(1, 1); in the act method?

Another Square Design

This exercise introduces another feature of Java that you can use to make some interesting graphics.

Add the statement private int side = 5; inside your class definition above all of the method definitions, so that the top of your file looks like this:

import greenfoot.*;

/**
 * Turtle that draws designs in the TurtleWorld.
 * 
 * @author TJ Leone 
 * @version June 2016
 */
public class Turtle extends SimpleTurtle
{
    private int side = 5;
    
	// all of your methods come after this.

Make sure your project still compiles. Resolve any compiler errors.

Change your act method to look like this:

    /**
     * Act - do whatever the Turtle wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        this.drawSquare(this.side);
        this.side += 5;
    }    

Make sure your project still compiles. Resolve any compiler errors.

Add a turtle somewhere near the upper right corner of your turtle world and press the Run button. What happens? Why?

When you've created a design you like, save it as "square-design-2"