25-oct-15 jeroo code. overview in this presentation we will discuss: how to write code in jeroo how...

16
Jun 18, 2 022 Jeroo Code

Upload: phebe-montgomery

Post on 03-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Apr 20, 2023

Jeroo Code

Page 2: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Overview

In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Page 3: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Review: Step 1. Create the Environment

To start: Open an existing Island File Or Create your own Island

Add or remove: Flowers Nets Water Land

You can save and re-use your islands.

Page 4: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Step 2. Write the program

You can create and control up to 4 Jeroos.

Your program must have a main method

Each Jeroo gets a name when it is created

Refer to them by name to send them a message

Page 5: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

The constructor statement

Jeroo alfred = new Jeroo() A new Jeroo is created and assigned the name alfred. alfred will appear in the top left corner of the island, facing

east.

All statements in the main program must specify which Jeroo is to act, and what it is to do. alfred.toss() tells alfred to toss a flower into the space ahead.

Page 6: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Coding practice

Write the code to create a new Jeroo named neo

Write the code to make neo hop

Write the code to make neo turn right.

Answers:

•Jeroo neo = new Jeroo();

•neo.hop( );

•neo.turn(RIGHT);

Page 7: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

hopping hop() alone means hop once in the direction the Jeroo is facing

hop(n) will tell the Jeroo to hop n times

Example: alexandria.hop(3);

is the same as: alexandria.hop(); alexandria.hop(); alexandria.hop();

Write the code to make neo hop forward 5 times .• neo.hop(5);

Page 8: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Step 3: Run the program

Animation shows Jeroos moving around the island Source code highlights while executing You can run one step at a time Run the whole program continuously Pause at any time Go back to the beginning, or stop

Page 9: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Watch a program running

the code is highlighted the Jeroo acts

Page 10: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Step 3: Run the program

3 different language modes

You want Java/C++/C#

Page 11: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Find the logic errors

Go to Jeroo and demonstrate and fix alexandria

Page 12: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Your First Program

Start Jeroo Enter your name 1. Create the environment

Clear the island layout. Place a flower at location Row 3 Column 2

2. Write the program Create a Jeroo with your name Tell it to hop to the flower Tell it to pick the flower

3. Run the program If it doesn’t work, fix it!

Page 13: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

The program goes in the main method

Create a Jeroo with your name Jeroo mrsH = new Jeroo( );

It will appear in location 0,0 facing EAST with no flowers in its pouch.

Tell it to hop onto the location with the flower mrsH.hop( );

You must address your Jeroo by name. repeat this statement each time you want your Jeroo to hop

mrsH.turn (relative direction); You must turn either LEFT or RIGHT

Tell it to pick the flower mrsH.pick( );

It will stop when it reaches the end of the program.

Page 14: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Top Grade

Write a program to get a Jeroo from one end of your original letter island to the other using AT LEAST 8 programming steps.

Add a comment to your code with your name in it and print the code.

(comments start with //)

Page 15: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

Choosing directions

Four relative directions LEFT RIGHT AHEAD HERE

Four compass directions NORTH SOUTH EAST WEST

When you turn, you must specify a relative direction

Page 16: 25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program

The End