activity 1.1.3 count me inarmstrong.bristoltwpsd.org/userfiles/servers/server... · web...
TRANSCRIPT
Activity 1.1.3 Count Me In Part 2Make Sure Part 1 is completed and printed before you continue to
part 2.
Introduction - If-Then-Else Statements
The if-then Statement
The if-then statement is the most basic of all the control flow statements. It tells your program to execute a certain section of code only if a particular test evaluates to true. For example, a bicycle
brakes will decrease the bicycle's speed only if the bicycle is already in motion.
If & if else - Tests a given condition. If the condition is true, performs the actions in a given sequence of blocks; otherwise, the blocks are ignored.
The if-then-else Statement
if then else
Tests a given condition. If the result is true, performs the actions in the -do sequence of blocks; otherwise, performs the actions in the -else sequence of blocks.
The if-then and if-then-else conditional statements let a computer program make simple decisions about what to do next. They work in the same logical way as we do when making decisions in real life. For example, when making a plan with a friend, I could say "If Mike gets home before 5.00pm then we'll go out for an early dinner or else if doesn’t come home before 5:00 pm then we order food in.” When 5.00pm arrives, the condition (i.e., Mike is home), which determines whether we all go out for an early dinner, will either be true or false. It's works exactly the same in coding
Click on the mutator to get the else block
© 2015 Project Lead The Way, Inc.
Introduction to Computer Science Activity 1.1.3 Count Me In – Page 1
Procedure - Make Sure Part 1 is completed and printed before you continue to part 2.
1. Work in pairs as pair programming. You and your partner need to help each other.
2. You will continue working on the TallyYName app that created yesterday. We have already decomposed a problem into smaller steps creating a backlog and sprint list.
Backlog - Person tallying wants to increment a counter so they can count people or things getting a total while counting. The blue highlighted area was completed in Part 1 (Yesterday’s assignment)
Sprint Task List for Backlog Item #1© 2015 Project Lead The Way, Inc.
Introduction to Computer Science Activity 1.1.3 Count Me In – Page 2
When the user presses a button, add 1 to a counter.
Make the interface attractive with an image for the button, some color, and a label for the counter.
Make a sound when the user presses a button so they know it has been pressed.
When the user presses a reset button, make the counter 0.
A label for the word total
A label to get the results that starts at 0
A checkbox can enable or disable whether the tally button works.
Make a sound when the user presses the Button_Tally so user know if it is locked and can’t be pressed to add the count
3. Open MIT App Inventor
4. Select My Project. Open the TallyYName app you created yesterday.
5. Make sure you have the buzzer sound downloaded from the btsd.us website. Path to Sound Select out school; staff directory, teacher page Mrs. Jones Computer Application, Grade 8 Computer Science, Lesson Plans Computer Science. Look Under Date; October 13, 2016 for file
6. Make a sound component to play a clicking sound when the button is pressed.
a. Drag a sound component from the Media drawer into the interface Viewer. Sound 2
© 2015 Project Lead The Way, Inc.
Introduction to Computer Science Activity 1.1.3 Count Me In – Page 3
Today’s work
b. Upload the sound file using the Media panel. The sound 2 buzzer.MP3 is in btsd.us
c. Select the sound component in the Components panel and then in the Properties panel, set the source to you’re the click.mp3 sound file.
7. The user wants to be able to carry the Android device around as they're tallying, but doesn't want to accidentally tally while holding the tablet when walking. The button is locked until you click the checkbox to unlock.
a. Add an “enabled” checkbox so that the user can enable or disable whether the tally button works. Add a checkbox in Designer view under the image. Text for checkbox is Enable Counter See below for what the designer .
8. Now go to the blocks view
© 2015 Project Lead The Way, Inc.
Introduction to Computer Science Activity 1.1.3 Count Me In – Page 4
Disable the code for the ButtonTally click on block code you currently have. Right-click on the when section of the code and choose disable
9. You will use the if-then block as shown here. Create the behavior that the tally button plays one sound if the checkbox is enabled and plays the other sound otherwise. You will probably want to use an if-then-else block, which you create as follows.
a. Use an if-then block and select its mutator, the blue gear.
b. Drag an else from the mutator palette on the left to the block configuration on the right.
© 2015 Project Lead The Way, Inc.
Introduction to Computer Science Activity 1.1.3 Count Me In – Page 5
Disable this code - Do NOT delete just disable – Right-click on tan event handler when ButtonTally Click and choose disable.
10. Code the button as shown below. What will happen is that if the checkbox is checked the count will be added otherwise it will make and buzzing sound telling you to unlock the button
11. Add a Text-to-Speech Component in the Designer View
12. Add a code to Button Tally if-then control under to Call the TextToSpeech 1 to Speak the message LabelCounterNumber Text
13. Test app if tablet are available. Show app to teacher ON tablet
© 2015 Project Lead The Way, Inc.
Introduction to Computer Science Activity 1.1.3 Count Me In – Page 6
14. Do a screen shot of the Blocks and the Designer View . Print
© 2015 Project Lead The Way, Inc.
Introduction to Computer Science Activity 1.1.3 Count Me In – Page 7