1 / 11

Methods

Methods. What will we learn today?. Object-Level Methods Built-in Methods of Alice Objects Example of object-level methods. Object Level Methods. A Method is a coordinated sequence of instructions that will be carried out when requested

eddied
Download Presentation

Methods

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. Methods

  2. What will we learn today? • Object-Level Methods • Built-in Methods of Alice Objects • Example of object-level methods

  3. Object Level Methods • A Method is a coordinated sequence of instructions that will be carried out when requested • An object level method is a method that defines new action(s) to be carried out by an object acting alone • Consider an example of a bird flying in the sky alone, the bird is not interacting with other birds or clouds. It is acting alone

  4. Methods of Alice Objects • As you have seen before, Alice provides a list of built-in methods associate with each object (those are the built-in object level methods) • However, you can write your own object level method to allow the object to perform the desired action(s) *The list of built-in methods of the Oryx object

  5. Confused Oryx Example • Looking for a breakfast in the desert, an Oryx (middle east) encounters a confused sign (roads and signs). She stares at sign and shakes her head. Oryx then hops left and turns toward the sign and then hops right and turns toward the sign and then left and then right. • Create a simulation that implements this comical story

  6. Confused Oryx Example • We need two object-level methods (hop left and hop right) Hop Left Do In Order Oryx turns left Oryx hops Oryx turns to face the sign Hop Right Do In Order Oryx turns right Oryx hops Oryx turns to face the sign

  7. Create your Own Method • In the object tree • Select the Oryx • Select “methods” tag in the details panel • Click the “create new method” button • Enter the name of the new method in the popup box • Click the “edit” button to the right of your method. Add the instructions for the method

  8. Calling a Method • In the World.my first method, alternately call the “hopLeft “and “hopRight “ methods twice to make the Oryx takes a zigzag path towards the sign

  9. The ‘HopLeft’ Methods

  10. The ‘HopRight’ Methods

  11. Let’s Work with Alice • One day a falcon was flying in the sky when it saw a little bunny hoping in the desert. So, the flacon flies down to hunt the bunny. The bunny tried to escape but unfortunately it couldn’t, the falcon caught it • Create the desired world • Write 3 object-levels methods; ‘Fly’ and ‘Hunt’ for the falcon and ‘Flee’ for the bunny • Create the animation as described in the story above Note: the falcon’s movement should be smooth and realistic, the wings should move when flying

More Related