diff --git a/docs/lessons/magic-8.md b/docs/lessons/magic-8.md index 6a8430c1..32e0d573 100644 --- a/docs/lessons/magic-8.md +++ b/docs/lessons/magic-8.md @@ -9,6 +9,7 @@ If (Conditionals) ## Quick Links * [activity](/lessons/magic-8/activity) +* [tutorial](/lessons/magic-8/tutorial) * [challenges](/lessons/magic-8/challenges) * [quiz](/lessons/magic-8/quiz) * [quiz answers](/lessons/magic-8/quiz-answers) diff --git a/docs/lessons/magic-8/activity.md b/docs/lessons/magic-8/activity.md index e087821e..00921bf2 100644 --- a/docs/lessons/magic-8/activity.md +++ b/docs/lessons/magic-8/activity.md @@ -1,8 +1,6 @@ # magic 8 activity -A fortune teller game on the micro:bit - -Welcome! This tutorial will help you create a magic 8 ball on the micro:bit. Let's get started! +Welcome! This activity will help you create a magic 8 ball on the micro:bit. Let's get started! Show a string to instruct the user how to play Magic 8! The magic 8 ball can only answer true or false questions. @@ -32,16 +30,13 @@ input.onGesture(Gesture.Shake, () => { Create a variable of type number called **randomNumber**. Set **randomNumber** to a random number with a limit of 2. Remember the random function in the math library, picks a random number from 0 to the limit, but not including the limit unless it is 0. ```blocks - basic.showString("ASK A QUESTION") basic.showNumber(8) input.onGesture(Gesture.Shake, () => { basic.clearScreen() - let randomNumber = Math.random(2) + let randomNumber = Math.random(3) }); - - ``` Create an if statement for the condition `if randomNumber = 2`. If **randomNumber** is 2, display the string 'Yes' @@ -52,7 +47,7 @@ basic.showString("ASK A QUESTION") basic.showNumber(8) input.onGesture(Gesture.Shake, () => { basic.clearScreen(); - let randomNumber = Math.random(2); + let randomNumber = Math.random(3); if (randomNumber == 2) { basic.showString("YES"); } @@ -68,7 +63,7 @@ basic.showString("ASK A QUESTION") basic.showNumber(8) input.onGesture(Gesture.Shake, () => { basic.clearScreen() - let randomNumber = Math.random(2) + let randomNumber = Math.random(3) if (randomNumber == 2) { basic.showString("YES") } else if (randomNumber == 1) { @@ -84,7 +79,7 @@ basic.showString("ASK A QUESTION") basic.showNumber(8) input.onGesture(Gesture.Shake, () => { basic.clearScreen() - let randomNumber = Math.random(2) + let randomNumber = Math.random(3) if (randomNumber == 2) { basic.showString("YES") } else if (randomNumber == 1) { @@ -106,14 +101,13 @@ basic.showString("ASK A QUESTION") basic.showNumber(8) input.onGesture(Gesture.Shake, () => { basic.clearScreen() - let randomNumber = Math.random(2) + let randomNumber = Math.random(3) if (randomNumber == 2) { basic.showString("YES") } else if (randomNumber == 1) { basic.showString("NO") } else { basic.showString("I DON'T KNOW") - } basic.showNumber(8) diff --git a/docs/lessons/magic-8/tutorial.md b/docs/lessons/magic-8/tutorial.md new file mode 100644 index 00000000..2e4b8291 --- /dev/null +++ b/docs/lessons/magic-8/tutorial.md @@ -0,0 +1,27 @@ +# Magic 8 tutorial + +Show a string to instruct the user how to play Magic 8! The magic 8 ball can only answer questions with "YES", "NO", or "MAYBE"... + +### Rebuild the game! + +The blocks have been shuffled! Put them back together so that... +* show "ASK A QUESTION" on the screen +* when the micro:bit is shaken, + * generate a random number between 0 and 2. + * if the number is `2`, show "YES" + * if the number is `1`, show "NO" + * otherwise show "MAYBE"... + +```shuffle +basic.showString("ASK A QUESTION") +input.onGesture(Gesture.Shake, () => { + let randomNumber = Math.random(3) + if (randomNumber == 2) { + basic.showString("YES") + } else if (randomNumber == 1) { + basic.showString("NO") + } else { + basic.showString("MAYBE") + } +}) +``` diff --git a/docs/lessons/magic-logo/activity.md b/docs/lessons/magic-logo/activity.md index 1f32c4c8..005745f3 100644 --- a/docs/lessons/magic-logo/activity.md +++ b/docs/lessons/magic-logo/activity.md @@ -30,8 +30,6 @@ input.onGesture(Gesture.LogoUp, () => { . . # . . `) }) - - ``` Run your code and try to turn around the micro:bit to see the **logo up** event in action!