Ejemplo n.º 1
0
        /// <summary>
        /// The full constructor for the GhostGame class.
        /// </summary>
        /// <param name="fileName"> The name of the dictionary file. </param>
        /// <param name="playerOne"> A reference to the first player. </param>
        /// <param name="playerTwo"> A reference to the second player. </param>
        public GhostGame(string fileName, GhostPlayer playerOne, GhostPlayer playerTwo)
        {
            _dictionary = new GhostDictionary(fileName);
            if (_dictionary.Size() == 0)
            {
                throw new Exception("Unable to load dictionary from " + fileName + ".");
            }

            _players[0] = playerOne;
            _players[1] = playerTwo;
        }
        /// <summary>
        /// A test harness for the GhostDictionary class.
        /// </summary>
        /// <param name="args"> The command line arguments passed in. </param>
        public static void TestGhostDictionary(string[] args)
        {
            if (args.Length == 1)
            {
                GhostDictionary dictionary = new GhostDictionary(args[0]);

                Console.WriteLine("Created dictionary with " + dictionary.Size() + " words, the longest having " + dictionary.MaxLength() + " letters.");
            }
            else
            {
                Console.WriteLine("Usage:  TestGhostDictionary " + typeof(GhostDictionary).FullName + " <word-list>");
            }
        }