I need it to randomly generate a word from the 'dictionary'. and then the user enter a letter or a guess. I have tried and failed. Here is my code:
I know there is a randGen line of code I could use but i am unsure how. Any help would be much appeciated
namespace Hangman2
{
class Hangman
{
static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.Red;
string Name;
string sInput;
//declaring the word array
string[] wordBank = new string[5];
wordBank[0] = "Dog";
wordBank[1] = "Computer";
wordBank[2] = "Tree";
wordBank[3] = "Balls";
wordBank[4] = "House";
//displaying the game layout
Console.WriteLine(" ************************ ");
Console.WriteLine(" * HANGMAN! * ");
Console.WriteLine(" ************************ ");
Console.WriteLine(" ________________ ");
Console.WriteLine(" | | ");
Console.WriteLine(" | ( ) ");
Console.WriteLine(" | /|\\ ");
Console.WriteLine(" | | ");
Console.WriteLine(" | /|\\ ");
Console.WriteLine(" | ");
Console.WriteLine(" | ");
Console.WriteLine(" |_______ ");
//Ask user to Enter Name
Console.Write("Enter your Name: ");
Name = Convert.ToString(Console.ReadLine());
Console.Clear();
//displaying user greeting message
Console.WriteLine(Name + ", Welcome");
Console.WriteLine(" ************************ ");
Console.WriteLine(" * HANGMAN! * ");
Console.WriteLine(" ************************ ");
Console.WriteLine();
//draw the hang structure
Console.WriteLine(" ______________ ");
Console.WriteLine(" |/ ");
Console.WriteLine(" | ");
Console.WriteLine(" | ");
Console.WriteLine(" | ");
Console.WriteLine(" | ");
Console.WriteLine(" | ");
Console.WriteLine(" |_______ ");
//declare the word list display/output condition
if (wordBank[0].Length == 3)
{
Console.WriteLine(" The word is : _ _ _ ");
}
else if (wordBank[1].Length == 8)
{
Console.WriteLine(" The word is : _ _ _ _ _ _ _ _ ");
}
else if (wordBank[2].Length == 4)
{
Console.WriteLine(" The word is : _ _ _ _ ");
}
else if (wordBank[3].Length == 5)
{
Console.WriteLine(" The word is : _ _ _ _ _ ");
}
else if (wordBank[4].Length == 5)
{
Console.WriteLine(" The word is : _ _ _ _ _ ");
}
Console.WriteLine();
Console.WriteLine(" ***Enter a new letter***");
sInput = Convert.ToString(Console.ReadLine());
Console.ReadKey();
}
}
}

New Topic/Question
Reply



MultiQuote




|