It is still a little scattered, but when debugging I can pick a letter, but it does not compare it to the wordArray/wordBank. So I am not able to "pick a letter" and it replace the * with the correct letter picked. I can't seem to figure out the code to do so.
Can anyone help?!?!?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace Hangman
{
class Program
{
static void Main(string[] args)
{
string Name;
string gameWord;
bool[] boolLetters;
char[] wordArray;
char[] letters;
char PlayerGuess;
// set geussable letters
letters = new char[26] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
// initializing all letters to false
boolLetters = new bool[26];
for (int i = 0; i < boolLetters.Length; i++)
{
boolLetters[i] = false;
}
// set word to null
gameWord = "";
// set wordArray to gameWord
wordArray = new char[1] { ' ' };
//declaring the word array
string[] wordBank = new string[9];
wordBank[0] = "Fishing";
wordBank[1] = "Computer";
wordBank[2] = "Tree";
wordBank[3] = "Location";
wordBank[4] = "Technician";
wordBank[5] = "Work";
wordBank[6] = "Butterfly";
wordBank[7] = "Toddler";
wordBank[8] = "Flowers";
//displaying the game layout
Console.WriteLine(" ~*~*~*~*~*~*~*~*~*~*~*~ ");
Console.WriteLine(" ~*~Welcome to Hangman!~*~ ");
Console.WriteLine(" ~*~*~*~*~*~*~*~*~*~*~*~ ");
//Ask user to Enter Name
Console.Write("Please enter your Name: ");
Name = Convert.ToString(Console.ReadLine());
//display user greeting message
Console.WriteLine(Name + ", Welcome, to Hangman");
Console.WriteLine(" ~*~*~*~*~*~*~*~*~*~*~*~ ");
Console.WriteLine(" ~*~*~Hangman!~*~*~ ");
Console.WriteLine(" ~*~*~*~*~*~*~*~*~*~*~*~ ");
Console.WriteLine();
// creates a random number to choose a word from word bank
Random random = new Random();
int randomNumber = random.Next(0, 9);
//selects the word from the wordBank using randomNumber
gameWord = wordBank[randomNumber];
// wordArray is set to wordArray
wordArray = new char[gameWord.Length];
wordArray = gameWord.ToCharArray();
//declare the word list display/output condition
if (wordBank[0].Length == 7)
{
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 == 8)
{
Console.WriteLine(" The word is : * * * * * * * *");
}
else if (wordBank[4].Length == 10)
{
Console.WriteLine(" The word is : * * * * * * * * * * ");
}
else if (wordBank[5].Length == 4)
{
Console.WriteLine(" The word is : * * * * ");
}
else if (wordBank[6].Length == 9)
{
Console.WriteLine(" The word is : * * * * * * * * * ");
}
else if (wordBank[7].Length == 7)
{
Console.WriteLine(" The word is : * * * * * * * ");
}
else if (wordBank[8].Length == 7)
{
Console.WriteLine(" The word is : * * * * * * * ");
}
string[] geuss = new string[gameWord.Length];
for (int i = 0; i < gameWord.Length; i++) ;
bool repeat = false;
do
{
Console.Write("Please enter a new letter: ");
string guess = Console.ReadLine();
if (guess.Length > 1)
{
Console.WriteLine("Only one letter is allowed");
repeat = true;
}
else
{
PlayerGuess = Convert.ToChar(guess);
if (char.IsLetter(PlayerGuess) == true)
{
PlayerGuess = char.ToUpper((char)PlayerGuess);
repeat = false;
}
else
{
Console.WriteLine("You can only enter letter values, please re-enter choice.");
repeat = true;
}
}
} while (repeat);
}
}
}