Presentation is loading. Please wait.

Presentation is loading. Please wait.

OOP features of Jeroo 3-Jul-19.

Similar presentations


Presentation on theme: "OOP features of Jeroo 3-Jul-19."— Presentation transcript:

1 OOP features of Jeroo 3-Jul-19

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: Dim Andy as Jeroo = 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 Dim Andy as Jeroo = new Jeroo() The methods of an object (the actions it can perform) Example: Andy.hop() Jeroos can hop, pick flowers, plant flowers, toss nets, and turn.

6 Syntax is important! A class is the type of an object
Each object that is created is named Dim Andy as Jeroo = new Jeroo(2,5,SOUTH,3); Andy is an object Jeroo is the class

7 Sending messages to objects
We don’t 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(WEST); 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


Download ppt "OOP features of Jeroo 3-Jul-19."

Similar presentations


Ads by Google