Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandParser"/> class.
        /// </summary>
        /// <param name="game">The <see cref="MinesweeperGame"/> object for which commands will be returned.</param>
        public CommandParser(MinesweeperGame game)
        {
            if (game == null)
            {
                throw new ArgumentNullException();
            }

            this.Game = game;

            // Create commands
            ICommand cmdRestart    = new CmdRestart(game);
            ICommand cmdBoom       = new CmdBoom(game);
            ICommand cmdShowScores = new CmdShowScores(game);
            ICommand cmdEndGame    = new CmdExit(game);
            ICommand cmdInvalid    = new CmdInvalid(game);

            this.commands = new Dictionary <string, ICommand>()
            {
                { "restart", cmdRestart },
                { "top", cmdShowScores },
                { "exit", cmdEndGame },
                { "boom", cmdBoom },
                { "invalid", cmdInvalid }
            };
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandParser"/> class.
        /// </summary>
        /// <param name="game">The <see cref="MinesweeperGame"/> object for which commands will be returned.</param>
        public CommandParser(MinesweeperGame game)
        {
            if (game == null)
            {
                throw new ArgumentNullException();
            }

            this.Game = game;

            // Create commands
            ICommand cmdRestart = new CmdRestart(game);
            ICommand cmdBoom = new CmdBoom(game);
            ICommand cmdShowScores = new CmdShowScores(game);
            ICommand cmdEndGame = new CmdExit(game);
            ICommand cmdInvalid = new CmdInvalid(game);

            this.commands = new Dictionary<string, ICommand>()
            {
                { "restart", cmdRestart },
                { "top", cmdShowScores },
                { "exit", cmdEndGame },
                { "boom", cmdBoom },
                { "invalid", cmdInvalid }
            };
        }
Example #3
0
 public CmdInvalid(CmdInvalid CopyThis)
     : base(CopyThis)
 {
 }
Example #4
0
 public void Test_CmdInvalid_CtorWithNullThrowsEx()
 {
     var cmd = new CmdInvalid(null);
 }