示例#1
0
        public ILegion CreateLegion(string legionType)
        {
            IFactionFactory factionFactory = null;

            switch (legionType.ToLower())
            {
            case "rebel":
                Legion         = new RebelArmy();
                factionFactory = new RebelFactionFactory();
                break;

            case "imperial":
                Legion         = new ImperialArmy();
                factionFactory = new ImperialFactionFactory();
                break;

            case "imperialimpostors":
                Legion         = new RebelArmy();
                factionFactory = new ImperialFactionFactory();
                break;
            }
            if (factionFactory != null)
            {
                Legion.PrepareArmy(factionFactory);
                return(Legion);
            }
            else
            {
                throw new ArgumentException("Could not initialize IFactionFactory");
            }
        }
 public ILegion CreateLegion(string legionType)
 {
     IFactionFactory factionFactory = null;
         switch (legionType.ToLower())
         {
             case "rebel":
                 Legion = new RebelArmy();
                 factionFactory = new RebelFactionFactory();
                 break;
             case "imperial":
                 Legion = new ImperialArmy();
                 factionFactory = new ImperialFactionFactory();
                 break;
             case "imperialimpostors":
                 Legion = new RebelArmy();
                 factionFactory = new ImperialFactionFactory();
                 break;
         }
         if (factionFactory != null)
         {
             Legion.PrepareArmy(factionFactory);
             return Legion;
         }
         else
         {
             throw new ArgumentException("Could not initialize IFactionFactory");
         }
 }