Presentation on theme: "As you come in… DOWNLOADS FOR TODAY: Alice Project: Wanda Dann and Don Slater, CMU What do you still need (Alice content/understanding)?"— Presentation transcript:
As you come in… DOWNLOADS FOR TODAY: Alice Project: Wanda Dann and Don Slater, CMU What do you still need (Alice content/understanding)? (Ill answer next week…) Index cards As many as you want Counted loops, nested loops, while loops, if statements, nested if statements, functions, expressions, compound boolean expressions, methods parameters
RSVP: Snacks next week Wrap up at 5:30 Snacks and beverages on the patio 5:30-6:30
Other administrative stuff?
Todays plan Methods and Parameters (Probably next time) Lists
Last Time… Module 2: Make Methods Escape FreakOut Apologize Did we – add a parameter to our methods? How many times should promGuy spin in his freakout? What should georgeBeetle say as an apology? What should promGuy say in his freakout?
One should use methods in programs primarily… A. For the computer B. For the person writing the program C. For people reading a program D. More than one of the above And WHY is it important?
How to make methods Think of ways in which your planned animation has natural parts Give each of the parts a name Put the code that makes that part happen in a method with that name Call that method from my first method, in the right order.
Example: Going to a movie… Walk up to ticket window Walking in group Buy tickets Interact with ticket seller (talking, hand over money, get tickets) Enter theater Walk through doors, hand tickets to worker, walk into lobby Buy snacks… Take seats… Make snarky critiques… …
Exercise! Choices… Choice 1: Set up the world yourself, or start with one we set up Do you want practice in setting up world? Focus on methods/parameters Which exercise: Helicopter Flight Beetle Band
Helicopter Flight  Create a world with a helicopter (Vehicles gallery), airport (Buildings), and a control tower (Buildings). Part A: Create a circleTower method that makes the helicopter fly toward the control tower and then around it. In my first method call the circleTower method twice, and then make the helicopter land on the landing strip. Part B: Modify circleTower to take a parameter indicating how many times it should go around the tower. Change the method call in myFirstMethod to only call the method once, but use a parameter to make it circle 2 time (then try 4 times). Add another object to the world (maybe a bird or flying dinosaur). Modify the circleTower method to take a second parameter which controls which object should circle the tower.  From Learning to Program with Alice textbook, do not use with students
Beetle Band  Create a world with a stage, and 4 beetles (Animals, Bugs) ringoBeetle, paulBeetle, Lennonbeetle, and georgeBeetle on it. Give them each an instrument (you can pick). Set the instruments vehicle to their beetle (whoever has that instrument). Create a method called paulSolo that makes paulBeetle do a solo but moving up and down while he spins around 1 revolution. Call this method from myFirstMethod. Modify the method to be called solo – and control which beetle dances by passing it as a parameter. In myFirstMethod, call solo so that each beetle does his solo in order from left to right. Modify the solo method to be more flexible by sending a parameter which is the number of spins a beetle should do when soloing  From Learning to Program with Alice textbook, do not use with students
Below: what happens after the last instruction in the mystery method is finished executing? A. The program starts the World.my first method B. The program goes back to my first method and calls method XXXXX C. The program goes back to my first method and calls method YYYYY D. We cant tell, we need to know more about the storyboard to be able to say
If we write a method called drive, which would not make sense as a parameter to control how drive occurs? A. Destination B. How fast C. Which car D. Car color
Which of the following is the best explanation of what makes a good parameter A. Its something that supports common variation in how the method is done B. Its got a meaningful name C. It can be either an Object or a number D. Its helps manage complexity in large programs