Activity : Using Selection Statements to Allow for Choices
In the last activity you used the Ask block to allow the user to enter some information you used in your story.
Open up your Jack and Jill story that you created in the last activity. (Feel free to remix our copy if you prefer http://scratch.mit.edu/projects/51670460/ )
Notice that while this was good, we always had a boy figure for Jack even if you told Mother Goose that your name was Margaret or Caroline or some other girl's name.
In this activity we will look at how you can use one of the two selection statements to have the story behave differently depending on which options a user puts into the story.
Make sure you have a copy of the Jack and Jill story open.
After we have asked the user their name, but before the story begins, we want to ask the user if they are a boy or a girl. Add this code to your program:
Now we want to change how we behave based on whether they said “boy” or “girl” IF they said boy, we want to make sure we are using a boy costume. ELSE (if they said girl) we want to make sure we are using a girl costume. One way to do this is to ask if they gave us answer of boy or not:
But we need to tell the computer what to do in each situation. Notice that Jack already has costumes for both a boy and a girl. Thus, when the story starts, we need to decide which costumes to use.
Repeat this same idea for each of the costume changes listed under Jack.
When you are done you should get code that looks like http://scratch.mit.edu/projects/51684630/
Things to think about when you are done
This project is based on materials from Dr. Ben Schafer at the University of Northern Iowa