Chapter 5: Methods and Parameters
Alice
The following programs are to be completed in the Alice developers
environment.
Gallop and Jump, Due Thursday
11/16
Kelly (people) has entered an equestrian show as an amateur
jumper. She is somewhat nervous about the competition so she and
her horse (animals) are practicing a jump. Create an intitial
scene with a horse and rider facing a fence (Buildings). Write
two world level methods, one named gallop (horse and rider gallop
forward one step) and another named jump (horse and ride jump the
fence). In the gallop method the horse's front legs should lift
and then go down as the back legs lift and the horse moves
forward. Then the back legs should go back down. The jump
method should be similar, but the horse should move up far enough to
clear the fence in mid stride. Test each method to be sure it
woks as expected.
Helicopter Flight, Due Friday
11/17
Create a world with a helicopter (vehicles in web gallery), airport
(buildings), and a control tower (buildings). 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
airport landing strip.
Magic Act, Due Monday 11/20
A magician is performing a levitation illusion, in which objects seem
to rise mgically into the air. The magician (people) points a
magic wand (objects) at his assistant (Girl from people folder) and she
gently rises into the air and floats back down to her original opision
on the table (furnature in web gallery). The magician performs
the same trick with the rabbit (Animals). The rabbit, being a
lighter object, floats up higher than the magician's assistant.
Because the magician's assitant and rabbit are each to levitate in the
same way, use a single method and use parameters to communicate which
object is to float and the distance the object is to move upwards (and
back down).
Funky Chicken Dance, Due
Wednesday 11/23
Starting with a basic chicken, create a class-level method walk that will have the chicken
perform a relalistic stepping motion consisting of a left setp followed
by a right step. Create a second method to make the chicken
perform a funkyChicken danse,
where the chicken walks and twists its body in all different
directions! Save the chicken as a new class named
CoolChicken. Create a new world and add a CoolChicken to the
world. In myFirstMethod,
call the walk and funkyChicken methods. Play a
sound file or use a say instruction to accompany the funky chicken
dance animation.
Clean Up Act, Due Monday 11/27
Create a scene of a room with toys scattered around the floor.
The gorilla robot (SciFi) can be programmed to pick up things in the
room and around the floor and put them behind the door in the
closetRoom (environments on web gallery). The initial scene for
this animation the robot is standing in the center of the room near
several objects scatttered around the floor. Write a program to
teach the robot to pick up one object at a time and put it in the
closet. Write three class level methods named pickup, putdown, and putInCloset. The methods
should have one parameter identifying the object to be picked up or put
down. The pickup method should make the robot put the object in
his hand. The putdown method should have the robot put the object
down. The putInCloset method should make the robot turn one half
revolution and move to the door. The door opens and the robot
puts down the object. When these methods have been written, then
write instructions in myfirst method to make the robot pick up objects
and put them in the closet.
Typing Tutor, Due Wednesday
11/29
In this exercise, you are to create a typing tutor that encouages
beginning typists to type a specific set of letters. Use 3D text
letters (3D text folder) to create a word in the world, (for example
you could create the word ALICE with the letters A, L, I, C, and
E. and create a method for each letter that spins the letter two
times. When the user types a letterkey on the keyboard that
matches the letter on the screen, the letter on the screen should
perform its spin method. Also include an additional method,
spinWord, which spins all the letters when the user presses the space
bar.
Snow Festival, Due Thursday
11/30
Your team has created a snowman as the centerpiece of an entry in the
winter snow festival competition. To attract to your display, you
have set up colored spotlights that will turn the color of the snowman
any one of the four different colors. Create an initial world
with four spotlights (spheres from the shapes folder) and a
snowman. Write only one method to change the color of the
snowman. When the user clics on a spotlight pass the color of the
spotlight to the method and make the snowman change to be that color.