5-oct-15 introduction and code. overview in this presentation we will discuss: what is jeroo? where...

23
Jun 16, 2 022 Introduction and Code

Upload: tobias-arnold

Post on 30-Dec-2015

223 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

Apr 19, 2023

Introduction and Code

Page 2: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

Overview

In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How to create islands, write code and run programs. Your first assignments.

Page 3: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

What is Jeroo?

An environment for learning object oriented programming in Java, Basic or Python. (OOP). you create objects and then do things with them.

Created in Java. It’s free. www.jeroo.org

Page 4: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

The story behind Jeroos

Jeroos similar to the wallabies of Australia have a pouch to hold flowers Winsum Flower: Jeroo's source of food

Where they live: Santong Island in the South Pacific can't swim – fur gets waterlogged-must dry

Humans arrive and set nets to catch Jeroos. Jeroos try to avoid the nets

Page 5: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

The Jeroo environment

The island is made of rows and columns. Locations are written ( row, column) The programmer chose to number both the rows and columns

starting with zero at the northwest corner of the island.

(0,0) (0,1)

(?)

(3,2)

NORTH

What location is this?

columns

rows 0

1

2

3

0 1 2 3 4

Page 6: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

What a Jeroo can do

A Jeroo can execute 6 action methods

1. hop() hop once or hop(n) to hop n times

2. turn(relative_direction )

3. pick() pick a flower

4. plant() plant a flower from the pouch

5. toss() throw a flower 1 space ahead.

6. give(relative direction) give a flower to another Jeroo

They always follow directions in order, from top to bottom.

Put it all together to solve various problems.

Four relative directions: LEFT RIGHT AHEAD HERE

When you turn or give, you must specify a relative directionturn(relative_direction ) give(relative direction)

Page 7: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

Creating a program in Jeroo

3 steps:1. Create the environment

2. Write the program

3. Run the program

Page 8: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

Step 1. Create the Environment

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

Add or remove: Flowers Nets Water

Be careful, this one is different: it resets the island Land

You can save and re-use your islands.

Page 9: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

Creating the Jeroo environment

To create your environment in Jeroo:

Left-click to draw

Right-click to remove

Page 10: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

Step 2. Write the program

You can create and control up to 4 Jeroos.

Your program must have a main method

{ curly braces } surround statements to group them together

In Java every statement ends with a ; semicolon

Each Jeroo gets a name when it is created

Page 11: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

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 12: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

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 13: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

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 14: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

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 15: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

Step 3: Run the program

3 different language modes

You want Java/C++/C#

Page 16: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

Watch a program running

the code is highlighted the Jeroo acts

Page 17: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

Find the logic errors

Go to Jeroo and demonstrate and fix alexandria

Page 18: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

Lab 1

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 19: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

The program goes in the main method

Create a Jeroo with your name Jeroo mrsOC = 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 mrsOC.hop( );

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

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

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

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

Page 20: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

Icons used to create and edit islands• Set the speed of the Jeroos• Create a new island layout• Open an existing island

• Save the island• Save as• Print• Plant flowers on the island

• Set nets on the island• Add water to the island• Clear the island layout (remove all

extra flowers, water and nets)• Get help with the Jeroo language

• Quit Jeroo

Page 21: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

Learn how to create islands.

Select water, flower or net

•left-click to add

•right-click to remove

Learn how to save islands.

Programs and islands are saved separately

•Source_file save (.jsc)

•Island_file save (.jev)

First Assignment

Create an attractive island based on your initials using water, land, flowers and nets.

Page 22: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

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 23: 5-Oct-15 Introduction and Code. Overview In this presentation we will discuss: What is Jeroo? Where can you get it? The story and syntax of Jeroo How

The End