180 likes | 266 Views
Using Accessor && Modifiers. Protecting your property. Add a bunny to your world. Add a new variable to the bunny Property. Write a function called isReadyToJump. Return isReadyToJump. Write method changeReadyToJump. Change the state of readyToJump.
E N D
Using Accessor && Modifiers Protecting your property
Create an act methodthat has an if statement using the isReadyToJumpFunction
Play • Click on the bunny • She moves up • Click on the bunny • What does she do? • What should she do? • Is this an error? • What kind of error?
Play • Click on the bunny • She moves up • Click on the bunny • She moves down
Do it all again with the a cat • Add a cat object into the world • Redo all the steps above for the cat
Use accessor and modifier methods in your code to alter the properties • Use this code a model when you are writing code for Tutorials 12-14 • If you need to go back and rewrite the code in previous tutorials • If statements are best when they use a function!