Git Product home page Git Product logo

kiddjsh / hangman Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 165 KB

An application, using a solution algorithm that employs loops, simple data structures, and arrays. The gaming application displays the input and output for a Hangman program, using my last name as the word to guess. The application prompts for a letter to be entered, when the letter is entered, it is checked against a list of valid character data types; if not correct, an error with a letter encryption is displayed; if correct, a message with the letter displays within the letter encryption.

License: MIT License

C# 100.00%

hangman's Introduction

hangMan

An application, using a solution algorithm that employs loops, simple data structures, and arrays. The gaming application displays the input and output for a Hangman program, using my last name as the word to guess. The application prompts for a letter to be entered, when the letter is entered, it is checked against a list of valid character data types; if not correct, an error with a letter encryption is displayed; if correct, a message with the letter displays within the letter encryption.

IPO Model

IPO Model_hangMan

Pseudocode

Pseudocode_hangMan_1 Pseudocode_hangMan_2

My C# Solution

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace hangMan_projectW6
{
    class Program
    {
        static void Main(string[] args)
        {
            char guess;
            char letter0 = 'k', letter1 = 'i', letter2 = 'd';
            char letter3 = 'd', letter4 = 'e', letter5 = 'r';
            char[] guessed = new char[26];
            char[] word = new char[] { letter0, letter1, letter2, letter3, letter4, letter5 };
            int score = 0;
            int noGuess = 0;
            int noCorrectGuess = 0;
            int wLength = word.Length;
            bool found;

            //letterDisplay
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine();

            //mysteryWord
            for (int i = 0; i < wLength; i++)
                guessed[i] = '*';

            //input
            while (noGuess <= 9)
            {
                found = false;
                Console.WriteLine();
                Console.WriteLine("Please enter a letter: ");
                guess = Convert.ToChar(Console.ReadLine());
                noGuess++;

                //loop
                for (int i = 0; i < wLength; i++)
                    if (word[i] == guess)
                    {
                        found = true;
                        guessed[i] = guess;
                        noCorrectGuess++;
                    }

                if (found)
                {
                    Console.WriteLine();
                    Console.WriteLine("You guessed correctly!");
                    found = true;
                }

                else
                {
                    Console.WriteLine();
                    Console.WriteLine("Incorrect. Try Again.");
                    score++;
                }    

                Console.WriteLine();
                Console.WriteLine(guessed);
                if (noCorrectGuess == wLength)
                    break;
            }

            if (noCorrectGuess == wLength)
            {
                Console.WriteLine();
                Console.WriteLine("You guessed the word: kidder!");
            }

            else
                Console.WriteLine();
                Console.WriteLine();
                Console.Write("You guessed " + score + " letters incorrectly.");

        Console.ReadLine();

        }
    }
      }

Complete Working Program

CWP_hangMan_1 CWP_hangMan_2 CWP_hangMan_3 CWP_hangMan_4 CWP_hangMan_5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.