Presentation is loading. Please wait.

Presentation is loading. Please wait.

Objects and Object-Oriented Programming CS 110 – Honors Slides by Wanda Dann, Ithaca College.

Similar presentations


Presentation on theme: "Objects and Object-Oriented Programming CS 110 – Honors Slides by Wanda Dann, Ithaca College."— Presentation transcript:

1 Objects and Object-Oriented Programming CS 110 – Honors Slides by Wanda Dann, Ithaca College

2 Objects 4 What is an object ? –any thing that can be identified as unique from other things 4 How is an object identified as unique? –has a name –has properties: width, height, color, location, age, ss#, id# –has a purpose: associated actions it can perform tasks it can carry out

3 Class 4 Objects are categorized into classes 4 Each object is an instance of the class. 4 All objects in a class have similar properties and generally can perform the same tasks. Person Dogs Peter Mary Paul Spike Scottie Fluffy

4 Objects in a Virtual World 4 In Alice, each 3-D model is an object –has a unique name Bunny, Bunny1, Bunny2 –has color(s) Pink, White, Grey, Black, Blue, …. –has 3 dimensions height, width, depth

5 Object Orientation 4 Each object has 6 degrees of orientation –front, back, left, right, up, down 4 Orientation is relative to the object itself –Bunny.move(left, 1, …) is a move to the Bunny's left 4 But, an object is aware of its orientation relative to other objects –Bunny.pointAt(Helicopter)

6 3-D Space 4 An object is located in 3-D space x y z x is left - right y is up - down z is front - back (0,0,0)

7 Repositioning 4 Movement of an object changes its position in space. 4 Some movements are translational –Bunny.move(back, 0.5, …) 4 Other movements are rotational –Bunny.turn(left, 0.5, …)

8 Motion Distance 4 Translational Distance –1 unit is about 1 meter (relative to the Virtual World dimensions) 4 Rotational Distance –1 unit is 1 rotation (360 degrees -- full turn) 4 Can specify –fractional parts of a unit 1/2 0.5 –multiple units 2

9 Instructions 4 An instruction such as Bunny.move(left, 1, …) is a statement that asks an object to perform an action or carry out a task. 4 Instructions must follow certain rules of syntax objectName.actionName(argumentList) 4 Note: –Instructions may have 0, 1, 2, … or more arguments –Some arguments are optional, some are required

10 Time 4 Animation takes time -- even on fancy computers! 4 By default, executing an instruction in Alice takes 1 unit of time (approx. 1 second) 4 You can specify the amount of time Bunny.move(left, 1, duration = 2) Note: This instruction would slow down the move -- how could you speed it up?

11 Object Parts 4 Many objects are made up of parts (we say they are composites) 4 A part of an object moves –with the entire object, by default –on its own, if given a specific instruction Bunny.head.leftear.turn(down, 1/8) –Syntax: objectName.partNameList.actionName(argumentList)

12 Object-Oriented Programming 4 An Alice program is: –a scene containing stationary objects -- like props on a stage active objects -- will move around the scene –a list of instructions that ask the objects to perform tasks in the virtual world 4 So, an Alice program is object-oriented.

13 Reading and Lab 4 See handouts. 4 Note: Lab exercises and projects require that you show me the code and execution of the programs created. I must "initial" your lab sheet for the exercises and projects or you will not get credit for them!


Download ppt "Objects and Object-Oriented Programming CS 110 – Honors Slides by Wanda Dann, Ithaca College."

Similar presentations


Ads by Google