2016-03-26 00:47:20 +01:00
|
|
|
# love meter blocks challenges
|
|
|
|
|
2016-11-02 01:44:37 +01:00
|
|
|
Create a love meter with the @boardname@
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
## Before we get started
|
|
|
|
|
2016-04-13 17:27:45 +02:00
|
|
|
You should work on these challenges after the following the [love meter activity](/lessons/love-meter/activity)
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
```blocks
|
|
|
|
input.onPinPressed(TouchPin.P0, () => {
|
2018-06-01 20:42:38 +02:00
|
|
|
let x = Math.randomRange(0, 10)
|
2016-03-26 00:47:20 +01:00
|
|
|
basic.showNumber(x)
|
|
|
|
})
|
|
|
|
|
|
|
|
```
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## Challenge 1
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
Add a pause of 3000 milliseconds (3 seconds) after showing the number so that the number won't immediately disappear in the next challenge.
|
|
|
|
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
input.onPinPressed(TouchPin.P0, () => {
|
2018-06-01 20:42:38 +02:00
|
|
|
let x = Math.randomRange(0, 10)
|
2016-03-26 00:47:20 +01:00
|
|
|
basic.showNumber(x)
|
|
|
|
basic.pause(3000)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## Challenge 2
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
If the rating **x** is between *0* and *3* (strictly less than *4*), display the text "HORRIBLE!".
|
|
|
|
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
input.onPinPressed(TouchPin.P0, () => {
|
2018-06-01 20:42:38 +02:00
|
|
|
let x = Math.randomRange(0, 10)
|
2016-03-26 00:47:20 +01:00
|
|
|
basic.showNumber(x)
|
|
|
|
basic.pause(3000)
|
|
|
|
if (x < 4) {
|
|
|
|
basic.showString("HORRIBLE")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## Challenge 3
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
**If** the rating is between 4 and 7, display the text "MEDIOCRE!" **else** display the text "MATCHED!"
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
input.onPinPressed(TouchPin.P0, () => {
|
2018-06-01 20:42:38 +02:00
|
|
|
let x = Math.randomRange(0, 10)
|
2016-03-26 00:47:20 +01:00
|
|
|
basic.showNumber(x)
|
|
|
|
basic.pause(3000)
|
|
|
|
if (x < 4) {
|
|
|
|
basic.showString("HORRIBLE")
|
|
|
|
} else if (x < 8) {
|
|
|
|
basic.showString("MEDIOCRE")
|
|
|
|
} else {
|
|
|
|
basic.showString("MATCHED")
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2017-09-07 22:42:08 +02:00
|
|
|
## Challenge 4
|
2016-03-26 00:47:20 +01:00
|
|
|
|
|
|
|
Use `show LEDs` to display images instead of text for each case.
|
|
|
|
|