I had been receiving help from The Lizard during a C# course a month or 2 back. He was very helpful, and hopefully he will see this message. The class ended but I wanted to finish the problems in the book to continue to learn as much as I could. Programming is not my major, but it was an enjoyable course so I wanted to finish the problems. If anyone can help me with this problem, or at least give me a kick in the right direction, I would appreciate it. I am having a lot of trouble with it, I really don't know what to do with the arrays and nothing I try seems to work. Below is the problem:
1. Write a console program similar to 'Hangman':
2. Create an array
of 10 words (you decide the words).
3. Randomly select a
word from the array.
4. Then prompt the
user to guess a letter of the word
5. Then if the
user's letter guesses matches any letter(s) in the word, then put the
letter guessed into the proper indices of another array and display the
contents at this point to the user.
Repeat till
either all letters are guessed or the user misses 3 times.
Include any necessary error handling.
Thanks in advance to any help.
Roy SPosted Aug 18, 2010, 8:06 PM
String[] words = new String[10] { "word1", "word2", ... }; //fill in all the words, replace the three dots with the rest of the words.
3. Create a random number from 0 to 9 and use that as index for the word to select a random word from the array
Random rand = new Random();
String selectedWord = words[rand.Next(10)];
4-5. I assume you already made a version of hangman without arrays so this part should be no problem.