DOC PREVIEW
USA CIS 115 - CIS 115 Lecture 09 Alice Ch 4-Classes Objects and Methods

This preview shows page 1-2-15-16-31-32 out of 32 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 32 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Classes / Objects / MethodsObject Oriented ProgrammingClassSlide 4ObjectsDog ObjectMethodsParametersLevels of MethodsCreate New MethodSlide 11Add Method InstructionsCalling a MethodSlide 14Slide 15Create Method with ParameterCreating ParameterParameterUse Parameter in MethodCalling Method with ParameterMultiple ParametersModify Method CallCreate Another MethodHomeworkClass MethodsGuidelines for Class MethodsInheritanceCreating a New Class in ALICERename ObjectSave As New ClassNew ClassSlide 32Classes / Objects / Classes / Objects / MethodsMethodsChapter 4Chapter 4Object Oriented ProgrammingObject Oriented ProgrammingDivides a program into Divides a program into Modules/ClassesModules/ClassesUses Classes and Objects to simulate Uses Classes and Objects to simulate real world environmentsreal world environmentsBasic Programming ComponentsBasic Programming Components•ClassesClasses•ObjectsObjects•MethodsMethodsClassClassSpecifies the definition of a particular Specifies the definition of a particular kind of objectkind of object•FrogFrog•SnowmanSnowman•Cell phoneCell phoneBlueprint / design for how to create Blueprint / design for how to create an object of that typean object of that typeClass names begin with a Capital Class names begin with a Capital letterletterClassClassPropertiesProperties•CharacteristicsCharacteristicsMethodsMethods•BehaviorsBehaviorsObjectsObjectsSpecific Instances of a ClassSpecific Instances of a ClassImplementation of the Class DefinitionImplementation of the Class Definition•Spot Spot  one specific dog one specific dog•Frosty Frosty  one specific snowman one specific snowmanAll specific objects of the same class share All specific objects of the same class share the same definitionthe same definition•Same Properties – can be modifiedSame Properties – can be modified•Same Methods – can be modifiedSame Methods – can be modifiedObject names begin with lowercase letterObject names begin with lowercase letterDog ObjectDog ObjectAll Instances of Class All Instances of Class Dog HaveDog Have•PropertiesPropertiesNameNameBreedBreedWeightWeightColorColor•MethodsMethodsWalkWalkBarkBarkJumpJumpEach Instance HasEach Instance Has•PropertiesPropertiesSpotSpotMuttMutt10 pounds10 poundsBlackBlack•MethodsMethodsWalkWalkBarkBarkJumpJump(can be modified to fit (can be modified to fit Spot’s requirements)Spot’s requirements)MethodsMethodsSequence of InstructionsSequence of InstructionsTasks that can be performedTasks that can be performedSome are predefined within the ClassSome are predefined within the Class•Dog has a bark methodDog has a bark methodOthers are Created or ModifiedOthers are Created or ModifiedMethods organize the programMethods organize the program•Divide the program into manageable Divide the program into manageable piecespiecesParametersParametersPieces of Information that need to be Pieces of Information that need to be sent to the Method sent to the Method Turn Toward (what)Turn Toward (what)Turn Toward SnowwomanTurn Toward SnowwomanLevels of MethodsLevels of MethodsGlobal Methods (World Level)Global Methods (World Level)•Methods that reference more than one Methods that reference more than one objectobjectClass MethodsClass Methods•Methods that define a behavior for one Methods that define a behavior for one single objectsingle objectCreate New MethodCreate New MethodSnowpeople (problem 4-1)Snowpeople (problem 4-1)•flipsHatflipsHatRaises right armRaises right armGrabs HatGrabs HatTips toward snowwomanTips toward snowwomanReturns Hat to HeadReturns Hat to HeadWorld Method World Method •Uses snowman and snowwomenUses snowman and snowwomen•WorldWorld•MethodMethod•Create New MethodCreate New Method•Name Name  flipsHat flipsHatAdd Method InstructionsAdd Method InstructionsCalling a MethodCalling a MethodNew Method must be “Called”New Method must be “Called”Program Instructions must indicate to Program Instructions must indicate to Execute the new MethodExecute the new MethodIn AliceIn Alice•Drag Method into World.MyFirstMethodDrag Method into World.MyFirstMethodIn Other LanguagesIn Other Languages•Call the Method using Method NameCall the Method using Method NameParametersParametersAllows communication with MethodsAllows communication with Methods•Communicate Values (Numbers, Colors)Communicate Values (Numbers, Colors)•Communicate Object NamesCommunicate Object NamesCreate Method with ParameterCreate Method with ParameterCreate Method called “dance”Create Method called “dance”•Object will jump up and down and spin aroundObject will jump up and down and spin aroundCreate ParametersCreate Parameters•Parameter 1Parameter 1Which object to danceWhich object to dance•Parameter 2Parameter 2 How many times to SpinHow many times to SpinCreating ParameterCreating ParameterWhich object to DanceWhich object to Dance•NameNameArbitrary Arbitrary Placeholder – holds place of the actual Placeholder – holds place of the actual object the will be used in the method object the will be used in the method •Type:Type:NumberNumberBoolean (True/False)Boolean (True/False)ObjectObjectOther (Sound, Color, Etc.)Other (Sound, Color, Etc.)ParameterParameterParameters show in Upper Left of Method Parameters show in Upper Left of Method PanelPanelWhen Method is Called (Used)When Method is Called (Used)•Object must be sent as an Argument to Method Object must be sent as an Argument to MethodUse Parameter in MethodUse Parameter in MethodCalling Method with ParameterCalling Method with ParameterWhen using Method you must include When using Method you must include ParameterParameterUse dance method after flipHatUse dance method after flipHatExample 1: Requires an object to Example 1: Requires an object to dancedanceMultiple ParametersMultiple ParametersAdd Second Parameter – How many Add Second Parameter – How many times to Spintimes to Spin•Name: numberToSpinName: numberToSpin•Type: NumberType: Number•Use in the Turn InstructionUse in the Turn InstructionModify Method CallModify Method CallChange 2Change 2ndnd Parameter Parameter Pick any 2 different numbersPick any 2 different numbersCreate Another MethodCreate Another MethodCreate a Method for


View Full Document

USA CIS 115 - CIS 115 Lecture 09 Alice Ch 4-Classes Objects and Methods

Documents in this Course
Load more
Download CIS 115 Lecture 09 Alice Ch 4-Classes Objects and Methods
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CIS 115 Lecture 09 Alice Ch 4-Classes Objects and Methods and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CIS 115 Lecture 09 Alice Ch 4-Classes Objects and Methods 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?