1 / 11

OOP features of Jeroo

OOP features of Jeroo. Overview. In this presentation we will discuss these topics: OOP terminology Jeroo syntax constructors methods. OOP syntax. Object oriented programming defines objects Each Jeroo you create is an object. an object has properties For example:

nonnie
Download Presentation

OOP features of Jeroo

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 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(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

More Related