As you come in* - CE21 San Diego

Report
As you come in…

DOWNLOADS FOR TODAY:
 http://ce21sandiego.org/2013


Alice Project: Wanda Dann and Don Slater, CMU
What do you still need (Alice
content/understanding)? (I’ll 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?
Today’s 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.
B.
C.
D.
For the computer
For the person writing the program
For people reading a program
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


Buy tickets





Interact with ticket seller (talking, hand over money, get
tickets)
Enter theater


Walking in group
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 [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
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
instrument’s “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
A.
B.
C.
D.
Below: what happens after the last instruction in the
mystery method is finished executing?
The program starts the World.my first method
The program goes back to my first method and calls
method XXXXX
The program goes back to my first method and calls
method YYYYY
We can’t 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.
B.
C.
D.
Destination
How fast
Which car
Car color
Which of the following is the best explanation of
what makes a good parameter
A.
B.
C.
D.
It’s something that supports common variation in
how the method is done
It’s got a meaningful name
It can be either an Object or a number
It’s helps manage complexity in large programs

similar documents