Because every student should have the opportunity to learn how to code

User Tools

Site Tools


lev3:act_selectionintro_s

Activity : Using Selection Statements to Allow for Choices

Ninja Instructions | Mentor Notes

Introduction

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.

Duration

15-30 minutes

Instructions

  1. Make sure you have a copy of the Jack and Jill story open.
  2. 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:

  3. 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:
  4. 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.

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

  • Now that you know about conditionals, what other kinds of questions could we have Mother Goose ask to improve this story?

Credits

This project is based on materials from Dr. Ben Schafer at the University of Northern Iowa

lev3/act_selectionintro_s.txt · Last modified: 2015/03/10 15:15 by jbschafer