static void Main(string[] args)
        {
            //创建工厂对象
            UndergraduateFactory uFactory = new UndergraduateFactory();
            VolunteerFactory     vFactory = new VolunteerFactory();

            //工厂返回雷锋(父类) 实际上是子类
            LeiFeng undergraduate = uFactory.CreateLeiFeng();
            LeiFeng volunteer     = vFactory.CreateLeiFeng();

            undergraduate.Sweep();
            volunteer.BuyRice();

            Console.ReadKey();
        }
Exemple #2
0
 static void Main(string[] args)
 {
     IFactory factory = new UndergraduateFactory();
     LeiFeng  student = factory.CreateLeiFeng();
 }