示例#1
0
        static void Main(string[] args)
        {
            BasePlayer physicalPlayer = new PhysicalPlayer();
            BasePlayer magicalPlayer  = new MagicalPlayer();

            BaseMonster flea = new Flea();
            BaseMonster bat  = new Bat();

            physicalPlayer.Attack(flea);
            physicalPlayer.Attack(bat);

            Console.WriteLine();

            magicalPlayer.Attack(flea);
            magicalPlayer.Attack(bat);
        }
示例#2
0
文件: Interface.cs 项目: lqt1912/GoF
 public abstract void DamagedBy(MagicalPlayer magicalPlayer);
示例#3
0
 public override void DamagedBy(MagicalPlayer magicalPlayer)
 {
     Console.WriteLine("Attacked by magical player! ");
     base.Damaged(100);
 }