Next page | Contents page |

Designing an application

So far we have worked with small chunks of program. Now let's think about how to go about creating a complete application.

We will take as an example the word game called Hangman which probably everyone knows. (If not, see the Wikipedia entry.)

Thinking about how the game works we might start to write an outline (programmers call it "high level" because it does not descend into details of how to do it):


  choose a phrase and display it as dashes;
  
  repeat
  {
    ask the user to guess a letter or the whole phrase;

    if guess length is 0
      tell user about error;
    else if guess length is 1 (guessing a letter)
    {

		Try writing the rest of this yourself
		before turning to the next page

    }	

    if diagram is complete
      game over - user LOSES;
	  
    if phrase is complete
      game over - User WINS;
  }
  until the game is over
Next page | Contents page |