Ejemplo n.º 1
0
        public static void EditWordBank()
        {
            bool     repeat   = true;
            WordBank wordBank = new WordBank();

            Console.WriteLine("Word Guessing Game Edit Menu");
            while (repeat)
            {
                string[] words = wordBank.GetAllWords();
                for (int i = 0; i < words.Length; i++)
                {
                    Console.WriteLine(words[i]);
                }
                Console.WriteLine("press 1 for Add");
                Console.WriteLine("press 2 for Delete");
                Console.WriteLine("press any key to exit");
                string userInput = Console.ReadLine();

                if (userInput == "1")
                {
                    Console.WriteLine("Enter your word");
                    string   word = Console.ReadLine();
                    string[] temp = { word };
                    wordBank.WriteToFile(temp);
                }
                else if (userInput == "2")
                {
                    Console.WriteLine("Enter word for deletion");
                    string word  = Console.ReadLine();
                    bool   match = false;
                    for (int i = 0; i < words.Length; i++)
                    {
                        if (words[i].Equals(word, StringComparison.CurrentCultureIgnoreCase))
                        {
                            match = true;
                            wordBank.DeleteWordFromFile(word);
                        }
                    }
                    if (match)
                    {
                        Console.WriteLine("Word delete");
                    }
                    else
                    {
                        Console.WriteLine("word does not exist");
                    }
                }
                else
                {
                    Console.WriteLine("Bye");
                    repeat = false;
                }
            }
        }
Ejemplo n.º 2
0
 public Game()
 {
     wordBank           = new WordBank();
     playerGuessHistory = new PlayerGuessHistory();
     Reset();
 }