Spoiler
Now, Im writing a quick console Hangman game, the problem is I discovered my approach required the building of a char array -> char[] from multiple char variables. I'm now lost, can someone point me in the right direction?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
string[] wordList = {
"Baseball", "Tackle", "Dubstep", "Ignorance", "Limitation", "Sausage",
"Destruction", "Patriot", "Computing", "Assembly", "Coding", "Hackers",
"Football", "Downward"
};
static void Main(string[] args)
{
int guessRemain = 7;
int wordSel = GenerateRandom();
Program o = new Program();
char[] wordChar = o.wordList[wordSel].ToLower().ToCharArray();
int MAX_BUF = wordChar.Length;
Console.WriteLine("\nHANGMAN v 1.0\n\n\n\n");
char[] userInput = PromptUserEntry();
char[] solution = ScanForMatchingLetter(wordChar, MAX_BUF, userInput);
Console.Read();
}
private static char ScanForMatchingLetter(char[] wordChar, int MAX_BUF, char[] userInput)
{
char[] solution = new char[MAX_BUF];
for (int i = 0; i < MAX_BUF; ++i)
{
if (userInput[0] == wordChar[i])
{
solution[i] = userInput[0];
}
}
return solution;
}
private static char[] PromptUserEntry()
{
Console.WriteLine("Pick a letter:");
char[] userInput = Console.ReadLine().ToCharArray();
return userInput;
}
private static void DisplayGuessLetterLine(char[] solution)
{
Console.Write(solution);
}
private static int GenerateRandom()
{
Random randNum = new Random();
int wordSel = randNum.Next(0, 13);
return wordSel;
}
}
}
Any input on the subject is greatly appreciate, and as you can see I'm not quite newbie but I still have a lot to learn. The goal is to receive help and give help, I learn better that way. Thank you!
This post has been edited by tlhIn`toq: 26 April 2012 - 09:04 PM
Reason for edit:: Added spoiler tags

New Topic/Question
This topic is locked



MultiQuote






|