Computer Science Canada Replacing Strings - for Hangman |
| Author: | bigbut600 [ Sun Nov 23, 2008 6:13 pm ] | ||
| Post subject: | Replacing Strings - for Hangman | ||
Hey, guys, I have to make a hangman game, no graphics needed, where a person would enter a word, and another person guesses letters that might be in the word. The program has to display dashes (-) to represent the word. For example- It should look something like this: Player 1 - Choose a word: ant (clear screen) --- Player 2 - The word has three letters. Choose a letter: e e is not in the word --- Player 2 - Choose a letter: a You found a letter! a-- Player 2 - Choose a letter: n You found a letter! an- You have used up all your guesses... etc That is what the program should do. But I am stuck on replacing letters entered by player 2 into the dashes that represent the word. I need HELP big time on that. I'm not very good. Can anyone please help me out? This is what I have so far...not very much though. Please try running it on your computer. You would have to play as both Players though, to test it out.
|
|||
| Author: | S_Grimm [ Sun Nov 23, 2008 6:17 pm ] |
| Post subject: | RE:Replacing Strings - for Hangman |
Look into the Draw procedures. there is a draw text one that you could use. (ie draw the --- then when one is correct draw the a--, etc) use Booleans and ifs inside a loop. Procedures also might make your life easier. |
|
| Author: | bigbut600 [ Sun Nov 23, 2008 6:29 pm ] |
| Post subject: | Re: RE:Replacing Strings - for Hangman |
A\V @ Sun Nov 23, 2008 6:17 pm wrote: Look into the Draw procedures. there is a draw text one that you could use. (ie draw the --- then when one is correct draw the a--, etc) use Booleans and ifs inside a loop. Procedures also might make your life easier.
I don't quite understand. I'm only allowed to use the things I've learned from school. Grade 10 Turing. All I know is that I've been learning how to replace strings before but none like this, because I never used something to represent a string before, in this case, the "-". I thought of someways of how I can do this but I don't know how to code it. 1st) I was thinking of looking in the actual word, and seeing what position of the letter is in the word, and then go to the dashes, find that position, and replace it with the letter. I don't know where to start coding from that. Any help? This seems to be the best way, in my point of view. |
|
| Author: | S_Grimm [ Sun Nov 23, 2008 6:56 pm ] | ||
| Post subject: | RE:Replacing Strings - for Hangman | ||
F10 is your new best friend. and without a whole lot of work, Drawing the font is easier. But it can be done. what you need is a boolean variable FOR EACH LETTER. then when letter 1 is guessed, the boolean variable for that letter becomes true. that way, an if statement will be sufficient
if your teacher hasn't taught you boolean variables and if statments, then he shouldn't be teaching. then are essential for any complex program. |
|||