class JianDanGongChang { static void Main( string [] args) { Factory factory = new LianXiangFactory(); DianNao dianNao = factory.Create(); dianNao.Print(); } } public abstract class DianNao { public abstract void Print(); } public class Lia
class JianDanGongChang { static void Main(string[] args) { Factory factory=new LianXiangFactory(); DianNao dianNao=factory.Create(); dianNao.Print(); } } public abstract class DianNao { public abstract void Print(); } public class LianXiang:DianNao { public override void Print() { Console.WriteLine("联想电脑"); } } public class DaiEr:DianNao { public override void Print() { Console.WriteLine("戴尔电脑"); } } public abstract class Factory { public abstract DianNao Create(); } public class LianXiangFactory:Factory { public override DianNao Create() { return new LianXiang(); } } public class DaiErFactory:Factory { public override DianNao Create() { return new DaiEr(); } }