//static void Main(string[] args)
        //{
        //    LeiFeng studentA = SimpleFactory.CreateLeiFeng("学雷锋的大学生");
        //    studentA.BuyRice();
        //    LeiFeng studentB = SimpleFactory.CreateLeiFeng("学雷锋的大学生");
        //    studentA.Sweep();
        //    LeiFeng studentC = SimpleFactory.CreateLeiFeng("学雷锋的大学生");
        //    studentA.Wash();

        //    Console.Read();
        //}
        #endregion


        #region 工厂方法学雷锋实现
        static void Main(string[] args)
        {
            IFactory factory = new UndergraduateFactory();
            LeiFeng  student = factory.CreateLeiFeng();

            student.BuyRice();
            student.Sweep();
            student.Wash();
            Console.Read();
        }
        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();
        }
Example #3
0
 static void Main(string[] args)
 {
     IFactory factory = new UndergraduateFactory();
     LeiFeng  student = factory.CreateLeiFeng();
 }