際際滷

際際滷Share a Scribd company logo
Hangman Program
Hangman Program
Hangman Program Pseudo Code
   START                                                                  evaluateGuess()
                                                                             while sub < SIZE
    Declarations
                                                                                if guess = word[sub] then
      num guess
                                                                                  guessCorrect = "Y"
      string WORD[9] = M, I, C, R, O, S, O, F,
    T                                                                           showWord[sub] = word[sub]
      string showWord[9] -, -, -, -,-, -, -, -, -,           endif
      string guessCorrect = N                                                sub = sub + 1
      string continueGame = Yes                                           endwhile
      num SIZE = 9
                                                                             if guessCorrect = "Y" then
      num sub = 0
      string WELCOME Welcome to Guess the Hidden Word!                        output MSG_Match
             Please enter a letter.                                           if word[9] = showWord[9] then
      string MSG_TRY_AGAIN Letters remain hidden. Please                        output MSG_Winner, showWord[9]
           enter another letter or QUIT to quit."                              guess = "QUIT"
      string MSG_NO_MATCH Sorry, Bad Guess!                                  else
      string MSG_MATCH Good_Guess!                                             output The Hidden Word now looks like, showWord[9]
      string MSG_WINNER = Congratulations, You are a
    Winner!                                                                       guessCorrect = "N"
             You have guessed the Hidden Word:                                  sub = 0
      string BYE Thank You for Playing! Goodbye!"                               output TRY_AGAIN
    getReady()                                                                   input guess
    while guess <> "QUIT"                                                      endif
      evaluateGuess()
                                                                              else
    endwhile
                                                                                 output MSG_NO_MATCH
    finish()
                                                                                 output The Hidden Word now looks like, showWord[9]
   STOP                                                                         sub = 0
                                                                                 output TRY_AGAIN
   getReady()                                                                   input guess
     output WELCOME                                                       return
     input guess
   return
                                                                           finish()
                                                                             output BYE
                                                                           return

More Related Content

Hangman Program

  • 3. Hangman Program Pseudo Code START evaluateGuess() while sub < SIZE Declarations if guess = word[sub] then num guess guessCorrect = "Y" string WORD[9] = M, I, C, R, O, S, O, F, T showWord[sub] = word[sub] string showWord[9] -, -, -, -,-, -, -, -, -, endif string guessCorrect = N sub = sub + 1 string continueGame = Yes endwhile num SIZE = 9 if guessCorrect = "Y" then num sub = 0 string WELCOME Welcome to Guess the Hidden Word! output MSG_Match Please enter a letter. if word[9] = showWord[9] then string MSG_TRY_AGAIN Letters remain hidden. Please output MSG_Winner, showWord[9] enter another letter or QUIT to quit." guess = "QUIT" string MSG_NO_MATCH Sorry, Bad Guess! else string MSG_MATCH Good_Guess! output The Hidden Word now looks like, showWord[9] string MSG_WINNER = Congratulations, You are a Winner! guessCorrect = "N" You have guessed the Hidden Word: sub = 0 string BYE Thank You for Playing! Goodbye!" output TRY_AGAIN getReady() input guess while guess <> "QUIT" endif evaluateGuess() else endwhile output MSG_NO_MATCH finish() output The Hidden Word now looks like, showWord[9] STOP sub = 0 output TRY_AGAIN getReady() input guess output WELCOME return input guess return finish() output BYE return