1
Answer

More help on the Console Hangman

Christina

Christina

14y
3.2k
1
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();
        }
    }
}


Answers (1)