public CommandDispatcher()
 {
     this.outHandler      = new OutputHandler();
     this.weapons         = new List <IWeapon>();
     this.inHandler       = new InputHandler();
     this.weaponFactory   = new WeaponFactory();
     this.gemFactory      = new GemFactory();
     this.weaponAttribute = (WeaponAttribute)typeof(Weapon).GetCustomAttributes(true).First();
 }
Beispiel #2
0
        public void Start()
        {
            IList <IWeapon>    weapons            = new List <IWeapon>();
            CommandInterpreter commandInterpreter = new CommandInterpreter();
            string             input = Console.ReadLine();

            while (!input.Equals("END"))
            {
                try
                {
                    string[] args           = input.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    ICommand currentCommand = commandInterpreter.GenerateCommand(args, weapons);
                    currentCommand.Execute();
                }
                catch (Exception ex)
                {
                    OutputHandler.WriteMessageInConsole(ex.Message);
                }

                input = Console.ReadLine();
            }
        }