Beispiel #1
0
        /**
         * Given a command: process (that is: Execute) the command.
         * Return true If the command ends the game, false otherwise.
         */
        private bool processCommand(Command command)
        {
            string cmd = command.GetCommandWord();

            if (!CommandMapper.isCommand(cmd))
            {
                Console.WriteLine("I don't know what you mean...");
                return(false);
            }
            bool toQuit;

            if (cmd == "help")
            {
                toQuit = helper.Execute(command);
            }
            else if (cmd == "go")
            {
                toQuit = goer.Execute(command);
            }
            else
            {
                toQuit = quitter.Execute(command);
            }
            return(toQuit);
        }
Beispiel #2
0
        /**
         * Given a command: process (that is: Execute) the command.
         * Return true If the command ends the game, false otherwise.
         */
        private bool processCommand(Command command)
        {
            if (!commandMapper.isCommand(command.CommandWord))
            {
                Console.WriteLine("I don't know what you mean...");
                return(false);
            }
            Response response = commandMapper.getResponse(command.CommandWord);

            return(response.Execute(command));
        }