Presentation is loading. Please wait.

Presentation is loading. Please wait.

13-Jun-14 OOP features of Jeroo. Overview In this presentation we will discuss these topics: OOP terminology Jeroo syntax constructors methods.

Similar presentations


Presentation on theme: "13-Jun-14 OOP features of Jeroo. Overview In this presentation we will discuss these topics: OOP terminology Jeroo syntax constructors methods."— Presentation transcript:

1 13-Jun-14 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: 1. What kind of data is in an object Example: a Jeroo object contains three types of information: 1. its location, 2. its direction, 3. and the number of flowers in its pouch. 2. How to make a new object of that class Example: Jeroo andy = new Jeroo(2,5,SOUTH,3); 1. Location = row 2, column 5 2. Direction = SOUTH 3. Holding 3 flowers The default constructor creates a Jeroo at location 0,0 facing EAST with no flowers Jeroo andy = new Jeroo(); 3. 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


Download ppt "13-Jun-14 OOP features of Jeroo. Overview In this presentation we will discuss these topics: OOP terminology Jeroo syntax constructors methods."

Similar presentations


Ads by Google