This is what i would like but not sure on the actual code to go about getting it....
//Draws the game display
function UpdateGameDisplay
Write contents of "hangboard" string to the console.
Write contents of "wordboard" string to the console. Write contents of "guessedletters" string to the console.
end function//Returns whatever the user enters, checks for errors
string function GetUserInput
Get character from console
Check that string is a single character and is valid (A-Z)
//Compares the user input to the already guessed letters, and updates as necessary
bool function CheckGuessedLetters(userletter)
//Check the guessed letters string to see if character has already been used.
loop each letter in "guessedletters"
if letter == userletter return true
end loop
Add letter to guessed letters string
return false
This is what i have:
namespace Console_Hangman
{
class Program
{
static void Main(string[] args)
{
// Displays the gamestart
Console.WriteLine("Welcome to Hangman, Let's Play.");
Console.WriteLine("Please Type Your Secret Word");
Console.ForegroundColor = ConsoleColor.Black;
string secretWord = Console.ReadLine();
string wordBoard = string.Empty;
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Your secret Word is");
Console.Write("");
for (int length = 0; length < secretWord.Length; length++)
{
wordBoard = wordBoard + "_";
}
Console.WriteLine(wordBoard);
Console.WriteLine("");
Console.WriteLine("Enter a letter");
Console.ReadLine();
}
}
}
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Steve JacksonPosted Apr 21, 2010, 12:59 PM
Your question reads as if you need help writing the entirety of the program. Generally, you'll have a better chance getting the help you need if you break the questions down into chunks that can be answered with less effort on the responder's part.
That said, you might consider breaking your code into several objects (or classes), or at least functions. I would have an object in charge of generating the words (WordGenerator), one in charge of validating response and keeping score (ScoreKeeper) and one in charge of graphics (GraphicsGenerator). I would use these objects for most of my work and keep the logic in the main class dedicated to simple user input and manipulating these objects.
If you decide to go that route, and need help coding the particular objects, I or one of the many (smarter than me) folks here can probably help.
Cheers