2
Two bugs at once
Computing 2: Unit 10, pp. 134–148
GoalFind the clues that show different kinds of bugs in a story with two characters.
New words
clue · a small sign that helps you find the answerreplay · to run the program againchecklist · a list of things to tick off
Explanation
A story can have two characters and two bugs. Look for clues. If a character never starts, the start block or the message colour may be wrong. If it goes too far, a number may be wrong. If things happen in the wrong order, the blocks may be in the wrong places. Fix one bug, then replay the story. Tick each bug on your checklist.
| Clue | Likely bug |
|---|---|
| a character never starts | wrong start block or message colour |
| a character goes too far | wrong number |
| things happen in the wrong order | blocks in the wrong places |
Worked examples
| Bug | Where | Fix |
|---|---|---|
| 1 | rabbit: hop 5 | change to hop 2 |
| 2 | fox: say before move | put the move block first |
The red outline shows the fox’s say block. It comes before the move block, but the algorithm says move first. We drag the say block after the move block.
| Bug | Fixed? |
|---|---|
| rabbit hops too high | yes |
| fox speaks too soon | not yet |
Class activity
Bug stickers (pairs): make a story program on paper with two characters and four blocks each. Draw a small paper dot on two blocks where you changed a number or a colour on purpose. Do not show your friend. Your friend reads the story aloud, compares it with your algorithm, and writes a checklist of the bugs. Then lift the dots and see if they found both.
Practice
1
The bus should drive right 5 and stop at the bus stop. When you run the story, it drives right off the edge of the page. What kind of bug could it be? How do you find it?
A wrong number: the move block probably says more than 5. Compare the block with the algorithm and change the number to 5.
2
A character should hop 2, but it hops 4. What kind of bug is this and how do you fix it?
A wrong number. Change the 4 to 2.
3
The algorithm is: start on green flag, move right 2, say “Hi!”, stop. Look at the program. How many bugs are there?
Two. The say block is before the move block, and the move block says 3 instead of 2.
4
Write a checklist for a story that has two bugs: the owl hops too high, and the mouse starts too soon.
Bug 1: the owl’s hop number is too big. Bug 2: the mouse’s start block is wrong. Each has a box to tick when it is fixed.