Any help/suggestions?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Hangman
{
class Program
{
static void Main(string[] args)
{
Console.Write("Welcome to Hangman! Please enter your guess: ");
//string mysteryWord = "mysteryword";
string[] wordBank = new string[10];
wordBank[0] = "sheep";
wordBank[1] = "handful";
wordBank[2] = "ihateprogramming";
wordBank[3] = "seventy";
wordBank[4] = "watermelon";
wordBank[5] = "squishy";
wordBank[6] = "litter";
wordBank[7] = "pineapple";
wordBank[8] = "startrek";
wordBank[9] = "starwars";
Random randGen = new Random();
string mysteryWord = randGen.ToString [wordBank [0,9]];
char[] guess = new char[mysteryWord.Length];
for (int p = 0; p < mysteryWord.Length; p++)
guess[p] = '*';
while(true)
{
Console.Write("Please enter your guess: ");
char playerGuess = char.Parse(Console.ReadLine());
for (int j=0; j < mysteryWord.Length; j++)
{
if (playerGuess == mysteryWord[j])
guess[j] = playerGuess;
}
Console.WriteLine(guess);
}
}
}
}

New Topic/Question
Reply
MultiQuote







|