1 / 18

Using Accessor && Modifiers

Using Accessor && Modifiers. Protecting you 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.

corrinet
Download Presentation

Using Accessor && Modifiers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Accessor && Modifiers Protecting you property

  2. Add a bunny to your world

  3. Add a new variable to the bunny Property

  4. Write a function called isReadyToJump

  5. Return isReadyToJump

  6. Write method changeReadyToJump

  7. Change the state of readyToJump

  8. Use the boolean not function from the World functions

  9. Create an act methodthat has an if statement using the isReadyToJumpFunction

  10. Create an event to make bunny.act

  11. 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?

  12. Change the act method so it changeReadyToJump

  13. Play • Click on the bunny • She moves up • Click on the bunny • She moves down

  14. Do it all again with the a cat • Add a cat object into the world • Redo all the steps above for the cat

  15. Create new world function

  16. Write new method called actWhenCatAndRabbitReady

  17. Add new event to when mouse taps ground use your new method

  18. 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!

More Related