Presentation is loading. Please wait.

Presentation is loading. Please wait.

As you come in… DOWNLOADS FOR TODAY: Alice Project: Wanda Dann and Don Slater, CMU What do you still need (Alice content/understanding)?

Similar presentations


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:

1 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

2 RSVP: Snacks next week Wrap up at 5:30 Snacks and beverages on the patio 5:30-6:30

3 Other administrative stuff?

4 Todays plan Methods and Parameters (Probably next time) Lists

5 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?

6 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?

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

8 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… …

9 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

10 Helicopter Flight [1] 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. [1] From Learning to Program with Alice textbook, do not use with students

11 Beetle Band [1] 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 [1] From Learning to Program with Alice textbook, do not use with students

12 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

13 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

14 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


Download ppt "As you come in… DOWNLOADS FOR TODAY: Alice Project: Wanda Dann and Don Slater, CMU What do you still need (Alice content/understanding)?"

Similar presentations


Ads by Google