示例#1
0
 // description: Resets both the shift value and the statistics from
 //				EncryptWord. Re-constructs the EncryptWord class.
 // input: none
 // processing: Re-Constructs EncryptWord. Calls the reset functions
 //             in EncryptWord. Lets the user
 //			   know that the game has been reset.
 // output: none
 private bool newGame()
 {
     game = new EncryptWord();
     game.resetShift();
     game.resetStats();
     return(true);
 }
示例#2
0
        // description: This method is used for testing purposes. It will run through
        //				all of the EncryptWord functions, testing them out. The result
        //				should be the same as playing the game yourself. This is just to
        //				save some time.
        // input: none
        // processing: Will proccess through all of the EncryptWord functions to test
        //				them out.
        // output: Any output included in the other functions will be included in this
        //			function as well.
        public void testEncryptWord()
        {
            const int SHIFT_MAX = 11;

            Console.WriteLine("Welcome to EncryptWord Test! This process is " +
                              "automated, no input is required.");
            Console.WriteLine("Now starting a new game, Test Game 1...");
            EncryptWord testGame1 = new EncryptWord();

            Console.WriteLine("New game created...");
            Console.WriteLine("The current stats should be at 0...");
            string testStats = testGame1.printStats();

            Console.WriteLine(testStats);

            string word1 = "Rhino", word2 = "LaRRy";
            string word3 = "ECLIPSE", word4 = "Egyptian";

            Console.WriteLine("Now testing the encrypt function...");
            Console.WriteLine("Inputting valid inputs...");
            Console.WriteLine("Inputting the word " + word1 + "...");
            Console.WriteLine("Encrypted " + word1 + " is " +
                              testGame1.encryptInput(word1));
            Console.WriteLine("Decoded: " + testGame1.decode());
            Console.WriteLine("Inputting the word " + word2 + "...");
            Console.WriteLine("Encrypted " + word2 + " is " +
                              testGame1.encryptInput(word2));
            Console.WriteLine("Decoded: " + testGame1.decode());
            Console.WriteLine("Inputting the word " + word3 + "...");
            Console.WriteLine("Encrypted " + word3 + " is " +
                              testGame1.encryptInput(word3));
            Console.WriteLine("Decoded: " + testGame1.decode());
            Console.WriteLine("Inputting the word " + word4 + "...");
            Console.WriteLine("Encrypted " + word4 + " is " +
                              testGame1.encryptInput(word4));
            Console.WriteLine("Decoded: " +
                              testGame1.decode());

            testStats = testGame1.printStats();
            Console.WriteLine("Current stats so far: " + testStats);

            Console.WriteLine("Attempting to guess the shift, " +
                              "will loop until correct...");
            for (int i = 0; i < SHIFT_MAX; i++)
            {
                if (testGame1.guessShift(i))
                {
                    Console.WriteLine(i + " is correct!");
                }
                else
                {
                    Console.WriteLine(i + " was not correct");
                }
            }

            testStats = testGame1.printStats();
            Console.WriteLine("Current stats so far: " + testStats);
            Console.WriteLine("You can still play the user-input " +
                              "version of the game.");
            Console.WriteLine("Use 'help' for a list of commands.");
        }