Hangman

Páginas: 4 (958 palabras) Publicado: 22 de diciembre de 2012
HangmanEXAMPLE PROJECT “HANGMAN”
The goal of this project was to write a graphically based game of hangman using Matlab. • The computer program opens a figure window, sets the axes properly and thendraws the "hangman" gallows. • The computer loads a dictionary of words that have been previously generated and saved as a text file. • The computer then selects any of those words randomly and putsthe correct number of dashes in the figure window. • The player can then start guessing letters. If the letter appears in the word then the computer puts the letter in its proper location. If not thenthe computer adds one more body part to the hangman. I used 6 body parts (e.g. head-neck, body, arms, legs, feet and hands). • If the entire body is completed then the player loses. If the playerguesses the word before the body is completed then the player wins. • After guessing a letter the letter should be removed from the available alphabet so that it is not guessed again. • The user shouldbe alerted if they try to guess the same letter more than once.

EXAMPLE PROJECT “HANGMAN”
USEFUL TIPS IN BUILDING LARGER PROGRAMS (1) Program in small steps. Complete on section of the code andtest it before moving on the next one. If you try to write the entire code in one shot without testing you will find it hard to locate and fix errors (i.e. bugs) (2) Use modular programming wheneverpossible. Instead of having one very large main program write a number of smaller programs ( called subroutines) that you call from the main program. This is a VERY good idea! The benefits are: a. youcan write and test each subroutine individually so you know each one works. b. you simplify considerably the main program which makes it easier to find errors. c. you can reuse code.

EXAMPLE PROJECT“HANGMAN”
STEP #1: SET UP THE FIGURE WINDOW AND AXES clc clear all clf % open figure window and set axis figure(1) axis([0 10 0 10]); axis('off') hold on

EXAMPLE PROJECT “HANGMAN”
NEXT STEP:...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • hangman
  • Hangman En Java (Pseudocodigo)

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS