Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //LeiFeng Undergraduate = new Undergraduate();
            //Undergraduate.BuyRice();
            LeiFeng studentA = SimpleFactory.CreateLeiFeng("大学生");

            studentA.Sweep();
            LeiFeng studentB = SimpleFactory.CreateLeiFeng("志愿者");

            studentB.BuyRice();

            IFactory factory  = new UndergraduateFactory();
            LeiFeng  student1 = factory.CreateLeiFeng();

            student1.BuyRice();
            student1.Sweep();
            student1.Wash();
        }
Ejemplo n.º 2
0
        public static LeiFeng CreateLeiFeng(string type)
        {
            LeiFeng result = null;

            switch (type)
            {
            case "大学生":
                result = new Undergraduate();
                break;

            case "志愿者":
                result = new Volunteer();
                break;

            default:
                break;
            }
            return(result);
        }