Monday 22 October 2012

Programs to build 3

Programs to build 3

Hangman
As much as hangman is quite a simple game, when you are learning to program it can be quite challenging to think about where you are going to start, and what you can realistically achieve.
You need to break the game down into sensible chunks, and building the program up bit by bit. You need to decide what programming syntax should be used in order to get the desired outcome.
Here is an example, thought up by year 9's as to the stages of hangman:

Stages of Hangman:
1. The computer thinks up a word
2. The computer tells the user how many letters are in the word
3. The user guesses a letter
4.a. If the letter is in the word, the computer outputs where abouts in the word it goes
4.b. If the letter is not in the word, the computer outputs the correct stage of the "hangman" cycle
5. Stages 4.a. and 4.b. repeat until the word is guessed or the user is "hung"

Stages of Programming a Simplified version of the Hangman game:
1.a. A simple guess the word game. As the programmer you define what the word is, the user gets one guess and are either right or wrong. The whole word is being guessed in one go.
1.b. The game continues until the user has guessed the word correctly.
2. A number of different words are stored in the program, and one is chosen by random. The user has to guess this word.
3. The word is broken down into letters (in the program) and the user has to guess each letter in the word.

No comments:

Post a Comment