make sure you are subscribed to announcements on moodle. activity 4 will be due 48hrs after your...

23
Lab 4: What is a List? Feb. 17 – Feb. 21

Upload: jennifer-banks

Post on 13-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Lab 4: What is a List?Feb. 17 – Feb. 21

Page 2: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Announcements

Make sure you are subscribed to announcements on Moodle.

Activity 4 will be due 48hrs after your lab ends

Page 3: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Key Concepts…

Variables› Script variable

Lists Loops Custom Blocks

› We can create 3 types of blocks; command, reporter and predicate.

Page 4: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Activity 4: Hangman

Hangman Rules:› There is a secret word to be guessed› The player guesses letters in the word until

either all letters are guessed and the word is known, or the player runs out of guesses.

› The program should give the player feedback on every guess

› The program should give the player feedback when they win or lose, say the number of guesses and the secret word.

Page 5: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Suggested Steps

Step 1: Choose a word Step 2: Word List. Step 3: Report number of letters in

Word Step 4: Begin Guessing! Step 5: Report number of guesses Step 6: Display letters Step 7: Report win or loss, play again?

Page 6: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 1: Choose a word

The Setter first enters the secret word by entering a response to an “ask” block.› The first thing we’ll need to do is have the

game ask one player for a word.› We can do this using sensing blocks.› We can define answer by setting it to a

variable

Page 7: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 1: Choose a word Notice we created a

block for “ask for word”

What does the shape tell us about the block› Command,

reporter, or predicate?

Page 8: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 2: Word List

The word is immediately hidden from view after the Setter finishes entering it.› After we have the word, we’ll need to store

it letter by letter. › Create a script that will go through the

word and store the letters, one by one, in a list.

› Consider the blocks below.

Page 9: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 2: Word List Create

variable letter_list

Again, notice the shape of this block.

Page 10: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 3: Report # of letters

The program starts by telling the Guesser how many letters are in the secret word.› We should tell the other player how long of

a word they are guessing› Use the “say” block, “join” block, “length

of list” block and the variables we just created.

Page 11: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 3: Report # of letters

“Length of list” block is a reporter block

Page 12: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 4: Begin Guessing

Guesser guesses a letter; the program tells the player whether their guess was right or wrong› Now, we want the second player to guess

letters until they run out of guesses or they guess the entire word.

› What kind of control blocks should we use; To do something over and over? To stop when something happens?

Page 13: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 4: Begin Guessing

List that shows correct letters as the game is being played. (similar to hangman blanks)

List that shows the guesses made by player

Page 14: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 4: Begin Guessing

Repeat until one of two things happen› Lives left equals zero or› Guess word, correctguess_list is equals to

letter_list

› If we want to repeat until this is TRUE…we will create _______ statements (reporter, predicate, command?)

Page 15: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 4: Begin Guessing

What belongs inside this repeat?› Simplify by creating code inside into a

block

Page 16: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 4: Begin Guessing Similar to “break word into list”

› Use script variables› “Ask” player to make a guess

Page 17: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 4: Begin Guessing

When the guesser guesses a letter, we want to show them where it appears in to actual word, if it does.› Already created a list of blanks the same

size as the actual word (correctguess_list)› Replace the blanks with the right letters as

they are guessed. What are the current list we have?

Page 18: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 4: Begin Guessing

What if the guess is wrong?

Page 19: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 5: Begin Guessing

If guess is wrong…› Report incorrect

guess› Take away a life› Reports # of lives

Page 20: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 6: Display letters

The program displays the letters guessed correctly so far, in their proper location in the word. › Need to make sure the correctguess_list

has the correct amount of blanks. Use “add _ to list”

› Allow the list to be seen on the stage.

Page 21: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 6: Display Letters

We want blanks to appear, and equal the same length of the word

Page 22: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 7: Report & Play again?

When the guesser either runs out of guesses or has successfully guessed the word the game ends. › Report a win or loss.› Ask if the player would like to play again

If yes, the game now ask the Guesser to become the Setter.

Repeat game. If player wants to play again, what

variables must be reset?

Page 23: Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends

Step 7: Report & Play again

Now, Customize your game!!