static void Main(string[] args) { Console.WriteLine("这里是魔兽世界"); #region 原始创建法 Console.WriteLine("****************原始创建法*****************"); //创建人类对象 Human original_human = new Human(); original_human.ShowKing(); //创建兽类对象 Orc original_orc = new Orc(); original_orc.ShowKing(); #endregion #region 接口创建法 Console.WriteLine("****************接口创建法*****************"); //创建人类对象 IRace interface_human = new Human(); interface_human.ShowKing(); #endregion #region 工厂参数创建法 Console.WriteLine("****************工厂参数创建法*****************"); //创建人类对象 IRace factory_human = Factory.CreateInstance(Factory.RaceType.Human); factory_human.ShowKing(); #endregion #region 工厂配置文件创建法 Console.WriteLine("****************工厂配置文件创建法*****************"); IRace factory_config_human = Factory.CreateInstanceConfig(); factory_config_human.ShowKing(); #endregion #region 工厂配置文件反射创建法 Console.WriteLine("****************工厂配置文件反射创建法*****************"); IRace factory_reflect_human = Factory.CreateInstanceReflect(); factory_reflect_human.ShowKing(); #endregion Console.Read(); }
static void Main(string[] args) { Console.WriteLine("欢迎大家来到软谋教育.net高级班公开课程"); Human human2 = new Human(); human2.ShowKing(); IRace human1 = new Human(); IRace human = Factory.CreateInstance(Factory.RaceType.Human); human.ShowKing(); //Orc orc = new Orc(); //IRace orc = new Orc(); IRace orc = Factory.CreateInstance(Factory.RaceType.Orc); orc.ShowKing(); IRace undead = Factory.CreateInstance(Factory.RaceType.Undead); undead.ShowKing(); Console.WriteLine("*********************CreateInstanceConfig**********************"); IRace iRace = Factory.CreateInstanceConfig(); iRace.ShowKing(); Console.WriteLine("*********************CreateInstanceReflect**********************"); IRace iRace2 = Factory.CreateInstanceReflect(); iRace2.ShowKing(); Console.Read(); }
public void PlayHuman(Human human) { Console.WriteLine("******************************"); Console.WriteLine("This is {0} Play War3.{1}", this.Name, human.GetType().Name); human.ShowKing(); }