Zmiany

Module 6 - The “Guess the NumberLogic Game” Project

Dodane 998 bajtów, 09:29, 6 lip 2015
[[Plik:Tip1.png|center]]
The first algorithm version may look like this:
''After the programme has been started:
* it displays a message telling you how to play, e.g. “I thought of a number between 1 and 100. Guess what number it is!”
* it draws a number (in the range from 1 to 100) and stores in a variable
* it displays the words “Give a number” and waits for the player’s answer
* it compares the player’s answer with the drawn number:
* if the number does not match
* it checks if the number given by the player is higher than the randomly selected number
* if it is
* it displays the message: “Too high!”
* otherwise
* it displays the message “Too low!”
* once again it prompts the player, waits for an answer and compares it with the drawn number
* if the number matches
* it displays “Well done!”
* it ends the script execution''
 
''After the first algorithm version has been written down we point out that we are dealing with certain actions which will be repeated.
''
'''We ask the following question:''' Which actions are repeated? Do we know how many times? Can we formulate a condition that must be met to terminate the repetition?
''If necessary, we guide students to realize that from the step “the programme compares the player’s answer” actions are repeated until the answer provided is correct (the provided number matches the number drawn by the programme). We point out it will be appropriate to use a relevant loop.''
181
edycji