Introduction

This tutorial shows you how to create and run a simple Jeroo program. More examples and more information about using Jeroo can be found in the tutorial document "Introduction to Jeroo" which is available from Jeroo's homepage (www.jeroo.org).

Santong Island

Conceptual Model

Appearance on the Screen



Practice

Watch the Cursor Location field under the island change as you move the cursor over the island. This field displays the current location of the cursor on the island.

A Problem to Solve

Write a program that will direct the Jeroo to pick the flower, use the flower to disable the net, and finish at the net's starting location facing EAST.


What Can A Jeroo Do?

To solve this problem, we need to know about Jeroo's action methods. A Jeroo can perform the seven separate actions listed below. To find out more about Jeroo's action methods, click on the "Help" menu, select the "Language Summary" item, then select the "Action Methods" tab from the Language Summary window.

A Jeroo can
  1. hop one space
  2. hop several spaces
  3. turn left or right
  4. pick a flower from its current location
  5. plant a flower at its current location
  6. give a flower to an adjacent Jeroo
  7. toss a flower to disable a net

Solution Plan

Observations

  1. The Jeroo starts facing East.
  2. The flower is exactly 4 spaces ahead of the Jeroo.
  3. The net is exactly 2 spaces South of the flower.
  4. The Jeroo's ending position will be the net's original position.
  5. The Jeroo must be facing East at the end.

Algorithm

Let's name the Jeroo Kim.
  • Instantiate (create) Kim
  • Kim hop four spaces
  • Kim pick the flower
  • Kim turn right
  • Kim hop once
  • Kim toss the flower to disable the net
  • Kim hop once
  • Kim turn left

The Program's Source Code

It's quite easy to convert the algorithm into a valid Jeroo program. The complete program is shown below.

method main()
{
   //--- instantiate the Jeroo ---
   Jeroo Kim = new Jeroo();

   //--- get the flower ---
   Kim.hop(4);
   Kim.pick();

   //--- disable the net ---
   Kim.turn(RIGHT);
   Kim.hop();
   Kim.toss();

   //--- finish up ---
   Kim.hop();
   Kim.turn(LEFT);
}  //===== end main() =====

Writing The Program

tabbed panes in Jeroo's window
This portion of the tutorial uses the tab panes in the left half of the Jeroo frame.

Normally, you would type the entire program into the "main method" tab in the left half of the Jeroo window. There are three ways to get this tutorial program into the "main method" tab.
  1. Click on the "main method" tab and type the code as it appears above. The capitalization and punctuation are important.
  2. Copy the program above and paste it into the "main method" tab.
  3. Click on the Copy The Code button below.
The first method is good practice, but you may want to use one of the other two.

Editing The Island


This portion of the tutorial uses the Island Edit menu and/or the corresponding toolbar buttons.

You need to use the mouse (or other pointing device) to place flowers, nets, and water on the island. The cursor always indicates the kind of object that you are adding to the island.

Practice

Practice placing and removing flowers, nets, and water until you are comfortable with the process. Notice that the Cursor Location field under the island always shows you the cursor's location. This makes it easier to place objects in specific locations.

When you are finished, clear the island by pressing the last in Island Edit group button on Jeroo's toolbar or by selecting Clear Island from the Island Edit menu.

Do It For Real

Configure the island for this problem.
  • Clear the island.
  • Place a single flower at location (0,4).
  • Place a single net at location (2,4).

Running The Program


This portion of the tutorial uses the Run menu and/or the corresponding toolbar buttons. We will study ways to run a program, and we will see what happens when a Jeroo hops into a net or into the water.

Make sure that the program is identical to that shown above. The source code, but not the island, is automatically saved each time you run a program. Since you have not yet saved the program, you will be asked to provide a file name the first time you run it. This is a one-time event.

Basic Running

Click the button with two triangles button on Jeroo's toolbar or select Run Continuously from the Run menu to run the program.

There are several things to notice when you run the program. When you are finished, click the button with triangle pointing to vertical line button on Jeroo's toolbar, or select Reset from the Run menu to reset the program and restore the island to its starting appearance.

Changing Speeds



The Run Speed menu and its associated slider can be used to change the speed at which the program executes. Try running the program at different speeds. Be sure to reset the program after each run.

Running Stepwise

Sometimes it helps to run the program one step at a time. This can be useful when we are trying to learn a new feature of the program or trying to locate the source of an error.

Click the button with one large triangle button or select Run Stepwise from the Run menu to start running the program step-by-step.

Changing Modes and Speeds

Jeroo allows you to switch back and forth between running stepwise and continuously. Jeroo also allows you to stop a program or change speeds while a program is running.

Water and Nets

This activity shows what happens when a Jeroo hops into a net or into the water. As you learn more about Jeroo, you will learn how to detect and avoid nets, water, and other Jeroos.

What's Next?

If you want to learn more about programming with Jeroo, work through the tutorial document "Introduction to Jeroo" which is available from Jeroo's homepage (www.jeroo.org).