Now we have created our three methods (escape, freakOut, and apologize). But just because we've created them doesn't mean they are being used. Now, we need to make use of the escape, freakOut, and apologize methods in our world.my first method location, otherwise we'll have wasted our time!
Step 1: Make sure world.my first method is open.
Step 2: Make sure world in the top-left corner of the screen is selected.
Step 3: Drag escape from the bottom-left corner panel into world.my first method, above all of the existing code.
Step 4: Drag freakOut from the bottom-left corner panel into world.my first method underneath world.escape
Step 5: Drag apologize from the bottom-left corner panel into world.my first method underneath world.freakOut
Your code should now look like this:
(click on the image to see it bigger)
[Q2.6.1]: What do you predict will happen when we run this program?
Now let's hit play to see our code executed!
Is this what you expected? Everything happened twice! But we just want it to happen once.
[Q2.6.2]: Why did everything happen twice?
Let's look at the code again. We included the escape, freakOut, and apologize methods, but we also left all of our original code in the world.my first method area. So the program is executing the code in escape, freakOut, and apologize, then doing the code that we left in there!
So let's finish our program.
Step 6: Remove all the original code from world.my first method. Only world.escape, world.freakOut, and world.apologize should be left in world.my first method.
Your code in world.my first method should now look like this: