SlideServe
Menu
Préférences
© SlideServe · v2026

CPSC 203 Tutorial

bela avatar
8 diapositives · 204 Views · Jul 18, 2014

CPSC 203 Tutorial. 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 functions Components of OOP Classes The types/templates of objects Objects The instances of classes

CPSC 203 Tutorial - slide 1
01 / 8CPSC 203 Tutorial
1 / 17

Télécharger la présentation

CPSC 203 Tutorial
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. CPSC 203 Tutorial 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