Jeroo
A Gentle
Introduction to the
Art of Object
Oriented
Programming
Jeroo
Santong
Island
Modeling a Jeroo
 Jeroo
– A graphical interface, similar to VB, used to
illustrate concepts we will study in this
course.
– We will learn how to write instructions
(programs) so that our programmable jeroos
can perform the tasks we give them.
 Unfortunately no variables
A Jeroo on its Island
Fundamental Jeroo Behaviors
 Jeroos are mobile.
– Can hop forward in the direction it is facing, from
corner to corner.
– Can turn in place.
 Jeroos can manipulate flowers.
– Can Pick flowers that they are on top of.
– Can plant a flower at their current location.
– Can toss a flower one space ahead.
– Can give a flower to a neighboring Jeroo
– Can determine if they are carrying any flower
 Jeroos can navigate by detecting the direction it is facing
(north, south, east, west).
Tasks
 A task is something that we want a jeroo
to do. Some examples are:
– Move to the corner of the island
– Run a hurdle race (jump over nets or water)
– Escape from a sectioned off fragment of
island
– Find a flower and place it at the origin.
– Escape from a maze.
– Harvest rows of flowers.
Jeroo
Primitive
Instructions and
Simple Programs
How Do We Tell the jeroo
What to Do?
 We give the jeroo instructions.
 A jeroo executes an instruction by
performing the instruction’s associated
action or actions.
 The jeroo executes a program by
executing a sequence of instructions that
are given to it by “the island god”.
Fundamental Jeroo Functions
 Changing position
hop()
– Hop one space ahead.
– The program terminates with a logic error if the
hopping Jeroo lands in the water, lands on another
Jeroo, or hops onto a net.
– A Jeroo can hop onto a flower.
turn(dir)
 Pivots 90 degrees in the specified direction.
– LEFT or RIGHT
Sending a message
 To send a message, we must specify the object
and the behavior for that object.
– A reference to the receiver object
– A period
– The message to be sent
 To send a message to a Jeroo:
silver.hop()
reference message
The Instructions
Silver = Jeroo(0, 0, East, 0)
silver.hop()
silver.hop()
silver.hop()
silver.turn(LEFT)
silver.hop()
silver.hop()
silver.hop()
// trace to see that it works
Sending a Message or invoking a function
Style Issues
 Programs should be indented nicely.
 Comments should be included.
 Programs should be well organized.
 Programs should be easy to read.

Intro to Jeroo Python

  • 1.
    Jeroo A Gentle Introduction tothe Art of Object Oriented Programming
  • 2.
  • 3.
    Modeling a Jeroo Jeroo – A graphical interface, similar to VB, used to illustrate concepts we will study in this course. – We will learn how to write instructions (programs) so that our programmable jeroos can perform the tasks we give them.  Unfortunately no variables
  • 4.
    A Jeroo onits Island
  • 5.
    Fundamental Jeroo Behaviors Jeroos are mobile. – Can hop forward in the direction it is facing, from corner to corner. – Can turn in place.  Jeroos can manipulate flowers. – Can Pick flowers that they are on top of. – Can plant a flower at their current location. – Can toss a flower one space ahead. – Can give a flower to a neighboring Jeroo – Can determine if they are carrying any flower  Jeroos can navigate by detecting the direction it is facing (north, south, east, west).
  • 6.
    Tasks  A taskis something that we want a jeroo to do. Some examples are: – Move to the corner of the island – Run a hurdle race (jump over nets or water) – Escape from a sectioned off fragment of island – Find a flower and place it at the origin. – Escape from a maze. – Harvest rows of flowers.
  • 7.
  • 8.
    How Do WeTell the jeroo What to Do?  We give the jeroo instructions.  A jeroo executes an instruction by performing the instruction’s associated action or actions.  The jeroo executes a program by executing a sequence of instructions that are given to it by “the island god”.
  • 9.
    Fundamental Jeroo Functions Changing position hop() – Hop one space ahead. – The program terminates with a logic error if the hopping Jeroo lands in the water, lands on another Jeroo, or hops onto a net. – A Jeroo can hop onto a flower. turn(dir)  Pivots 90 degrees in the specified direction. – LEFT or RIGHT
  • 10.
    Sending a message To send a message, we must specify the object and the behavior for that object. – A reference to the receiver object – A period – The message to be sent  To send a message to a Jeroo: silver.hop() reference message
  • 11.
    The Instructions Silver =Jeroo(0, 0, East, 0) silver.hop() silver.hop() silver.hop() silver.turn(LEFT) silver.hop() silver.hop() silver.hop() // trace to see that it works Sending a Message or invoking a function
  • 12.
    Style Issues  Programsshould be indented nicely.  Comments should be included.  Programs should be well organized.  Programs should be easy to read.