Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Hangman
- {
- class Program
- {
- static string[] mistakesChar = new string[7];
- static string head = "O";
- static string neck = "|";
- static string arm1 = "/";
- static string arm2 = "\\";
- static string body = "|";
- static string leg1 = "/";
- static string leg2 = "\\";
- static int currentMistakes = 0;
- static string[] words = new string[] { "about", "above", "across", "act", "active", "activity", "add", "afraid", "after", "again", "age", "ago", "agree", "air", "all", "alone", "along", "already", "always", "am", "amount", "an", "and", "angry", "another", "answer", "any", "anyone", "anything", "anytime", "appear", "apple", "are", "area", "arm", "army", "around", "arrive", "art", "as", "ask", "at", "attack", "aunt", "autumn", "away", "baby", "base", "back", "bad", "bag", "ball", "bank", "basket", "bath", "be", "bean", "bear", "beautiful", "beer", "bed", "bedroom", "behave", "before", "begin", "behind", "bell", "below", "besides", "best", "better", "between", "big", "bird", "birth", "birthday", "bit", "bite", "black", "bleed", "block", "blood", "blow", "blue", "board", "boat", "body", "boil", "bone", "book", "border", "born", "borrow", "both", "bottle", "bottom", "bowl", "box", "boy", "branch", "brave", "bread", "break", "breakfast", "breathe", "bridge", "bright", "bring", "brother", "brown", "brush", "build", "burn", "business", "bus", "busy", "but", "buy", "by", "cake", "call", "can", "candle", "cap", "car", "card", "care", "careful", "careless", "carry", "case", "cat", "catch", "central", "century", "certain", "chair", "chance", "change", "chase", "cheap", "cheese", "chicken", "child", "children", "chocolate", "choice", "choose", "circle", "city", "class", "clever", "clean", "clear", "climb", "clock", "cloth", "clothes", "cloud", "cloudy", "close", "coffee", "coat", "coin", "cold", "collect", "colour", "comb", "come", "comfortable", "common", "compare", "complete", "computer", "condition", "continue", "control", "cook", "cool", "copper", "corn", "corner", "correct", "cost", "contain", "count", "country", "course", "cover", "crash", "cross", "cry", "cup", "cupboard", "cut", "dance", "dangerous", "dark", "daughter", "day", "dead", "decide", "decrease", "deep", "deer", "depend", "desk", "destroy", "develop", "die", "different", "difficult", "dinner", "direction", "dirty", "discover", "dish", "do", "dog", "door", "double", "down", "draw", "dream", "dress", "drink", "drive", "drop", "dry", "duck", "dust", "duty", "each", "ear", "early", "earn", "earth", "east", "easy", "eat", "education", "effect", "egg", "eight", "either", "electric", "elephant", "else", "empty", "end", "enemy", "enjoy", "enough", "enter", "equal", "entrance", "escape", "even", "evening", "event", "ever", "every", "everyone", "exact", "everybody", "examination", "example", "except", "excited", "exercise", "expect", "expensive", "explain", "extremely", "eye", "face", "fact", "fail", "fall", "false", "family", "famous", "far", "farm", "father", "fast", "fat", "fault", "fear", "feed", "feel", "female", "fever", "few", "fight", "fill", "film", "find", "fine", "finger", "finish", "fire", "first", "fit", "five", "fix", "flag", "flat", "float", "floor", "flour", "flower", "fly", "fold", "food", "fool", "foot", "football", "for", "force", "foreign", "forest", "forget", "forgive", "fork", "form", "fox", "four", "free", "freedom", "freeze", "fresh", "friend", "friendly", "from", "front", "fruit", "full", "fun", "funny", "furniture", "further", "future", "game", "garden", "gate", "general", "gentleman", "get", "gift", "give", "glad", "glass", "go", "goat", "god", "gold", "good", "goodbye", "grandfather", "grandmother", "grass", "grave", "great", "green", "grey", "ground", "group", "grow", "gun", "hair", "half", "hall", "hammer", "hand", "happen", "happy", "hard", "hat", "hate", "have", "he", "head", "healthy", "hear", "heavy", "hello", "help", "heart", "heaven", "height", "hen", "her", "here", "hers", "hide", "high", "hill", "him", "his", "hit", "hobby", "hold", "hole", "holiday", "home", "hope", "horse", "hospital", "hot", "hotel", "house", "how", "hundred", "hungry", "hour", "hurry", "husband", "hurt", "ice", "idea", "important", "increase", "inside", "into", "introduce", "invent", "iron", "invite", "is", "island", "jelly", "job", "join", "juice", "jump", "just", "keep", "key", "kill", "kind", "king", "kitchen", "knee", "knife", "knock", "know", "ladder", "lady", "lamp", "land", "large", "last", "late", "lately", "laugh", "lazy", "lead", "leaf", "learn", "leave", "leg", "left", "lend", "length", "less", "lesson", "let", "letter", "library", "lie", "life", "light", "like", "lion", "lip", "list", "listen", "little", "live", "lock", "lonely", "long", "look", "lose", "lot", "love", "low", "lower", "luck", "machine", "main", "make", "male", "man", "many", "map", "mark", "market", "marry", "matter", "may", "me", "meal", "mean", "measure", "meat", "medicine", "meet", "member", "mention", "method", "middle", "milk", "million", "mind", "minute", "miss", "mistake", "mix", "model", "modern", "moment", "money", "monkey", "month", "moon", "more", "morning", "most", "mother", "mountain", "mouth", "move", "much", "music", "must", "my", "name", "narrow", "nation", "nature", "near", "nearly", "neck", "need", "needle", "neighbour", "neither", "net", "never", "new", "news", "newspaper", "next", "nice", "night", "nine", "no", "noble", "noise", "none", "nor", "north", "nose", "not", "nothing", "notice", "now", "number", "obey", "object", "ocean", "of", "off", "offer", "office", "often", "oil", "old", "on", "one", "only", "open", "opposite", "or", "orange", "order", "other", "our", "out", "outside", "over", "own", "page", "pain", "paint", "pair", "pan", "paper", "parent", "park", "part", "partner", "party", "pass", "past", "path", "pay", "peace", "pen", "pencil", "people", "pepper", "per", "perfect", "period", "person", "petrol", "photograph", "piano", "pick", "picture", "piece", "pig", "pin", "pink", "place", "plane", "plant", "plastic", "plate", "play", "please", "pleased", "plenty", "pocket", "point", "poison", "police", "polite", "pool", "poor", "popular", "position", "possible", "potato", "pour", "power", "present", "press", "pretty", "prevent", "price", "prince", "prison", "private", "prize", "probably", "problem", "produce", "promise", "proper", "protect", "provide", "public", "pull", "punish", "pupil", "push", "put", "queen", "question", "quick", "quiet", "quite", "radio", "rain", "rainy", "raise", "reach", "read", "ready", "real", "really", "receive", "record", "red", "remember", "remind", "remove", "rent", "repair", "repeat", "reply", "report", "rest", "restaurant", "result", "return", "rice", "rich", "ride", "right", "ring", "rise", "road", "rob", "rock", "room", "round", "rubber", "rude", "rule", "ruler", "run", "rush", "sad", "safe", "sail", "salt", "same", "sand", "save", "say", "school", "science", "scissors", "search", "seat", "second", "see", "seem", "sell", "send", "sentence", "serve", "seven", "several", "sex", "shade", "shadow", "shake", "shape", "share", "sharp", "she", "sheep", "sheet", "shelf", "shine", "ship", "shirt", "shoe", "shoot", "shop", "short", "should", "shoulder", "shout", "show", "sick", "side", "signal", "silence", "silly", "silver", "similar", "simple", "single", "since", "sing", "sink", "sister", "sit", "six", "size", "skill", "skin", "skirt", "sky", "sleep", "slip", "slow", "small", "smell", "smile", "smoke", "snow", "so", "soap", "sock", "soft", "some", "someone", "something", "sometimes", "son", "soon", "sorry", "sound", "soup", "south", "space", "speak", "special", "speed", "spell", "spend", "spoon", "sport", "spread", "spring", "square", "stamp", "stand", "star", "start", "station", "stay", "steal", "steam", "step", "still", "stomach", "stone", "stop", "store", "storm", "story", "strange", "street", "strong", "structure", "student", "study", "stupid", "subject", "substance", "successful", "such", "sudden", "sugar", "suitable", "summer", "sun", "sunny", "support", "sure", "surprise", "sweet", "swim", "sword", "table", "take", "talk", "tall", "taste", "taxi", "tea", "teach", "team", "tear", "telephone", "television", "tell", "ten", "tennis", "terrible", "test", "than", "that", "the", "their", "then", "there", "therefore", "these", "thick", "thin", "thing", "think", "third", "this", "though", "threat", "three", "tidy", "tie", "title", "to", "today", "toe", "together", "tomorrow", "tonight", "too", "tool", "tooth", "top", "total", "touch", "town", "train", "tram", "travel", "tree", "trouble", "true", "trust", "twice", "try", "turn", "type", "uncle", "under", "understand", "unit", "until", "up", "use", "useful", "usual", "usually", "vegetable", "very", "village", "voice", "visit", "wait", "wake", "walk", "want", "warm", "wash", "waste", "watch", "water", "way", "we", "weak", "wear", "weather", "wedding", "week", "weight", "welcome", "well", "west", "wet", "what", "wheel", "when", "where", "which", "while", "white", "who", "why", "wide", "wife", "wild", "will", "win", "wind", "window", "wine", "winter", "wire", "wise", "wish", "with", "without", "woman", "wonder", "word", "work", "world", "worry", "worst", "write", "wrong", "year", "yes", "yesterday", "yet", "you", "young", "your", "zero", "zoo", };
- static string currentWord;
- static char[] charWord;
- static char[] guessedLettersWrong = new char[] { };
- static void Main(string[] args)
- {
- Console.ForegroundColor = ConsoleColor.White;
- PickWord();
- Array.Resize(ref charWord, currentWord.Length);
- for (int i = 0; i < charWord.Length; i++) charWord[i] = '-';
- DrawHangman(currentMistakes);
- while (true)
- {
- char currentChar = ' ';
- bool correctChar = false;
- while (!correctChar)
- {
- try
- {
- currentChar = Console.ReadLine()[0];
- }
- catch
- {
- Console.WriteLine("Invalid letter!");
- System.Threading.Thread.Sleep(1000);
- currentMistakes -= 1;
- }
- correctChar = true;
- }
- bool letterRight = false;
- for (int i = 0; i < currentWord.Length; i++)
- {
- if (currentChar == currentWord[i])
- {
- letterRight = true;
- charWord[i] = currentChar;
- }
- }
- if (!letterRight)
- {
- currentMistakes += 1;
- Array.Resize(ref guessedLettersWrong, guessedLettersWrong.Length + 1);
- guessedLettersWrong[guessedLettersWrong.Length - 1] = currentChar;
- }
- DrawHangman(currentMistakes);
- bool solved = true;
- for (int i = 0; i < charWord.Length; i++)
- {
- if (charWord[i] == '-')
- {
- solved = false;
- }
- }
- if (solved == true)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("You win!");
- Console.ForegroundColor = ConsoleColor.White;
- break;
- }
- if (currentMistakes >= 7)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("You lost!");
- Console.ForegroundColor = ConsoleColor.White;
- Console.WriteLine("The word was: {0}", currentWord);
- break;
- }
- }
- Console.WriteLine("vk.com/dandelay");
- Console.ReadLine();
- }
- static void PickWord()
- {
- Random rnd = new Random();
- int word = rnd.Next(0, words.Length - 1);
- currentWord = words[word];
- }
- static void DrawHangman(int mistakes)
- {
- Console.Clear();
- for (int i = 0; i < mistakesChar.Length; i++)
- mistakesChar[i] = " ";
- if (mistakes > 0)
- mistakesChar[0] = head;
- if (mistakes > 1)
- mistakesChar[1] = neck;
- if (mistakes > 2)
- mistakesChar[2] = arm1;
- if (mistakes > 3)
- mistakesChar[3] = arm2;
- if (mistakes > 4)
- mistakesChar[4] = body;
- if (mistakes > 5)
- mistakesChar[5] = leg1;
- if (mistakes > 6)
- mistakesChar[6] = leg2;
- Console.WriteLine();
- Console.WriteLine(" ######");
- Console.WriteLine(" # " + mistakesChar[0]);
- Console.WriteLine(" # {0}{1}{2}", mistakesChar[2], mistakesChar[1], mistakesChar[3]);
- Console.WriteLine(" # {0}", mistakesChar[4]);
- Console.WriteLine(" # {0} {1}", mistakesChar[5], mistakesChar[6]);
- Console.WriteLine(" #");
- Console.WriteLine("####");
- Console.WriteLine();
- Console.Write("You guessed: ");
- for (int i = 0; i < charWord.Length; i++) Console.Write(charWord[i]);
- Console.WriteLine();
- try
- {
- Console.Write("You didnt guess: ");
- for (int i = 0; i < guessedLettersWrong.Length; i++) Console.Write(guessedLettersWrong[i] + " ");
- Console.WriteLine();
- }
- catch
- {
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment