Last active
August 29, 2015 14:19
-
-
Save no-longer-on-githu-b/5b5ac73aaaf0d9ccd8bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
identification division. | |
program-id. hangman. | |
data division. | |
working-storage section. | |
01 state. | |
05 word pic A(100). | |
05 word-length pic 9(3). | |
05 guess pic A. | |
05 guesses occurs 256 times pic 9. | |
05 done pic 9. | |
01 i pic 9(3). | |
procedure division. | |
* TODO: pick random word from word list | |
move "hello" to word | |
move 5 to word-length | |
* TODO: show this in debug mode only | |
display "word: " word | |
perform until done = 1 | |
accept guess | |
move 1 to guesses(function ord(guess)) | |
move 1 to done | |
perform varying i from 1 by 1 until i > word-length | |
if guesses(function ord(word(i:1))) = 1 then | |
display word(i:1) with no advancing | |
else | |
move 0 to done | |
display "_" with no advancing | |
end-if | |
end-perform | |
display " " | |
end-perform. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment