Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is what you should do</p> <ol> <li>Create an array a and put dashes equal to the number of the letters in the word</li> <li>Display that (step 1) to the user</li> <li>When the user guess the right letter, put the letter in the right position in array a</li> <li>Go to step 2</li> </ol> <p>Read this <a href="http://en.wikipedia.org/wiki/Hangman_(game)" rel="nofollow">http://en.wikipedia.org/wiki/Hangman_(game)</a></p> <p>Here is a code I just wrote</p> <pre><code> static void Main(string[] args) { string secreteWord = "Arizona"; //have a dash array equal to the number of the letters of the secret word char[] a = new char[secreteWord.Length]; for (int i = 0; i &lt; a.Length; i++) { a[i] = '_'; } // Tell the user the number of letters through the dashes for (int i = 0; i &lt;a.Length ; i++) { Console.Write(a[i]+ " "); } // ask the user to guess Console.WriteLine(); int count = 0; do { Console.WriteLine("Enter your guess letter"); char input = Console.ReadLine().ToCharArray()[0]; for (int i = 0; i &lt; secreteWord.Length; i++) { //if the user guessed right, replace the correct dash and display to the user if (secreteWord[i] == input) { count++; //update the count to check when to exit a[i] = input; //here if the user guess correct, we replace the dash with the input //now we display the dash array after it is modified for (int j = 0; j &lt; a.Length; j++) { Console.Write(a[j] + " "); } } } Console.WriteLine(); } while (count &lt; a.Length); Console.WriteLine("You guessed it right"); Console.ReadLine(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload