Beispiel #1
0
        public override void Execute(string[] commandArgs)
        {
            string    shipName = commandArgs[1];
            IStarship ship     = this.GetStarshipByName(shipName);

            System.Console.WriteLine(ship.ToString());
        }
Beispiel #2
0
        public override void Execute(string[] commandArgs)
        {
            string    shipName = commandArgs[1];
            IStarship ship     = this.GameEngine.Starships.First(s => s.Name == shipName);

            Console.WriteLine(ship.ToString());
        }
        public override void Execute(string[] commandArgs)
        {
            string    shipName = commandArgs[1];
            IStarship ship     = null;

            bool shipAlreadyExists = this.GameEngine.Starships
                                     .Any(s => s.Name == shipName);

            if (!shipAlreadyExists)
            {
                throw new ArgumentOutOfRangeException("Starship {0} does not exist!", shipName);
            }

            foreach (IStarship starship in this.GameEngine.Starships)
            {
                if (starship.Name == shipName)
                {
                    ship = starship;
                }
            }

            Console.WriteLine(ship.ToString());
        }