OOP features of Jeroo - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

OOP features of Jeroo

Description:

The method is a name of the action we want the object to take ... island, water, flower, net, jeroo. constructor: a way to create an object. ... – PowerPoint PPT presentation

Number of Views:154
Avg rating:3.0/5.0
Slides: 12
Provided by: dianneme
Category:
Tags: oop | all | features | flower | jeroo | name

less

Transcript and Presenter's Notes

Title: OOP features of Jeroo


1
OOP features of Jeroo
2
Overview
  • In this presentation we will discuss these
    topics
  • OOP terminology
  • Jeroo syntax
  • constructors
  • methods

3
OOP syntax
  • Object oriented programming defines objects
  • Each Jeroo you create is an object.
  • an object has properties
  • For example
  • a Jeroo has a location
  • number of flowers in its pouch
  • a direction it is facing
  • an object has methods (things it can do)
  • a Jeroo can hop, pick, plant and toss.

these properties must be set to an initial value
when the Jeroo is created, and change as the
Jeroo acts.
4
Classes definitions of objects
  • When you create a new object it is constructed.
  • An object may be constructed a number of
    different ways.

this is the default constructor
5
Classes
  • A class describes 3 things
  • What kind of data is in an object
  • Example a Jeroo object contains three types of
    information
  • its location,
  • its direction,
  • and the number of flowers in its pouch.
  • How to make a new object of that class
  • Example Jeroo andy new Jeroo(2,5,SOUTH,3)
  • Location row 2, column 5
  • Direction SOUTH
  • Holding 3 flowers
  • The default constructor creates a Jeroo at
    location 0,0 facing EAST with no flowers
  • Jeroo andy new Jeroo()
  • The methods of an object (the actions it can
    perform)
  • Example andy.hop()
  • Jeroos can hop, pick flowers, plant flowers,
    toss flowers into nets, give flower to another
    Jeroo, and turn.

6
Syntax is important!
  • A class is the type of an object
  • Each object that is created is named
  • Jeroo andy new Jeroo(2,5,SOUTH,3)
  • andy is an object
  • Jeroo is the class

7
Sending messages to objects
  • We dont perform operations on objects, we talk
    to them
  • This is called sending a message to the object
  • A message looks like this
  • object.method(extra information)
  • The object is the thing we are talking to
  • The method is a name of the action we want the
    object to take
  • The extra information is anything required by the
    method in order to do its job (also called a
    parameter)
  • Examples
  • andy.turn(RIGHT)
  • susanna.toss() no extra
    information needed

8
Messages and methods
  • Messages can be used to
  • Give an object some information
  • Tell an object to do something
  • Ask an object for information (usually about
    itself)
  • Any and all combinations of the above
  • A method is something inside the object that
    responds to your messages
  • A message contains commands to do something

9
Using OOP syntax
  • Rewrite the following English statements as
    object oriented messages
  • Tell the woman named clarissa to walk 2 steps
  • clarissa.walk(2)
  • Tell the Jeroo named alan to turn to the right
  • alan.turn(RIGHT)

10
Vocabulary Review
  • class the type, or description, of an object
  • Jeroo classes are descriptions of
  • island, water, flower, net, jeroo
  • constructor a way to create an object. comes as
    part of the class definition.
  • object an instance, or member, of a class
  • You can only create Jeroos in your code, all
    other objects must be created visually.
  • message something that you say to an object,
    either telling it something or asking it for
    information
  • parameter information sent to a method

11
The End
Write a Comment
User Comments (0)
About PowerShow.com