TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Lee
NA
1
8.2k
Can anyone see anything wrong with coding for a simple hangman game?
Dec 20 2010 10:17 AM
static void HangmanEasy()
{
List<string> word = new List<string>();
word.Add("ABLE");
word.Add("ACHE");
word.Add("ACID");
word.Add("AERO");
word.Add("AFRO");
word.Add("AUTO");
word.Add("BABE");
word.Add("BAKE");
word.Add("BALD");
word.Add("BALL");
word.Add("BAND");
word.Add("BANG");
word.Add("BANK");
word.Add("BARK");
word.Add("BARN");
word.Add("BASE");
word.Add("BASS");
word.Add("BATH");
word.Add("BEAR");
word.Add("BEER");
word.Add("BIKE");
word.Add("BITE");
word.Add("BIRD");
word.Add("BODY");
word.Add("BOMB");
word.Add("BURN");
word.Add("BUSH");
word.Add("CAFE");
word.Add("CAKE");
word.Add("CALM");
string[] FourLetterWords = new string[word.Count];
for (int i = 0; i < word.Count; i++)
{
FourLetterWords[i] = word[i];
}
string fourWord = FourLetterWords[r.Next(1, (word.Count + 1))];
char[] letters = fourWord.ToCharArray();
string[] empty = new string[4];
for (int a = 0; a < empty.Length; a++)
{
empty[a] = "_";
}
Play:
Console.Clear();
Console.WriteLine("Choose your letters and lets play!");
Console.WriteLine("----------------------------------");
Console.WriteLine("");
Console.WriteLine(" " + empty[0] + " " + empty[1] + " " + empty[2] + " " + empty[3]);
Console.WriteLine("");
string letterChoice = Console.ReadLine().ToUpper();
char[] letter = letterChoice.ToCharArray();
for (int pos = 0; pos < letters.Length; pos ++)
{
if (letters[pos] == letter[0])
{
empty[pos] = letterChoice;
goto Play;
}
else
{
goto Play;
}
}
Reply
Answers (
1
)
I-plexus clearing House Sender and receiver ID needed
Google AdSense Report