Presentation is loading. Please wait.

Presentation is loading. Please wait.

Xin Liu Nov 24, 2010. Object-oriented programming A mimic of real world The world is composed of objects An object has some properties and methods and.

Similar presentations


Presentation on theme: "Xin Liu Nov 24, 2010. Object-oriented programming A mimic of real world The world is composed of objects An object has some properties and methods and."— Presentation transcript:

1 Xin Liu Nov 24, 2010

2 Object-oriented programming A mimic of real world The world is composed of objects An object has some properties and methods and functions Components of OOP Classes The types/templates of objects Objects The instances of classes Different objects can be created from the same class The objects share the same methods but can have different names and properties Methods A method is an action that an object can take, actually composed of a sequence of instructions.

3 Exercise Create two objects from the camel class, named as Camelo and Camely. Camelo has red ears; Camely has blue ears. Camelo is bigger; Camely is smaller.

4 More on methods Build-in methods User-defined methods Class-level methods The actions of an object E.g. Iceskater.roll and Bunny.hop World-level methods The actions involving more than one objects E.g. World.Iceskater discusses with Snowman World.my first method is the “main program” we used to work on

5 Exercise Go through Tutorial 2.

6 Exercise Download and open lab4ggypt.a2w Create a class-level method on Pharaoh, getScared Beard enlarged by 1.2; nose enlarged by1.2; hat turns 1 rev; says “Aaaaah!” Create a world-level method, getScared Camera focuses on the Pharaoh Show the mummy scared Call world.getScared from world.myFirstMethod

7 Exercise Add a class-level method, getScared, to Mummy Head grows by 1.2 and then shrinks by 1/1.2; yells “Oooooh!” at the same time. Edit the world-level method, getScared Focus the camera to the mummy Call mummy.getScared Add a dummy object at the camera’s original position Edit the world-level method, getScared Turn the camera back

8 Summary Two class-level methods One world-level method A neat program is obtained by splitting the code into class and world-level methods


Download ppt "Xin Liu Nov 24, 2010. Object-oriented programming A mimic of real world The world is composed of objects An object has some properties and methods and."

Similar presentations


Ads by Google