コード例 #1
0
        static void Main(string[] args)
        {
            var army       = new Army();
            var platoon    = new Platoon();
            var elfPlatoon = new PlatoonAdapter(new Platoon());

            elfPlatoon.AddWarrior(new Elf());
            elfPlatoon.AddWarrior(new Elf());
            platoon.AddWarrior(new Elf());
            platoon.AddWarrior(elfPlatoon);

            army.AddPlatoon(platoon);

            army.AddPlatoon(new Orc());

            army.AddPlatoon(new Hydra());

            army.AddPlatoon(new Cyclop());

            army.AddPlatoon(new Knight());

            foreach (var slogan in army.SayAllSlogans())
            {
                Console.WriteLine(slogan);
            }
        }
コード例 #2
0
 public void AddWarrior(IWarrior warrior)
 {
     _platoon.AddWarrior(warrior);
 }