Пример #1
0
        static void Main(string[] args)
        {
            LeiFeng studentA = SimpleFactory.CreateLeiFeng("学雷锋的大学生");

            studentA.Sweep();
            LeiFeng studentB = SimpleFactory.CreateLeiFeng("学雷锋的大学生");

            studentB.Wash();
            LeiFeng volunteer = SimpleFactory.CreateLeiFeng("社区志愿者");

            volunteer.BuyRice();

            Console.ReadLine();
        }
Пример #2
0
        public static LeiFeng CreateLeiFeng(string type)
        {
            LeiFeng result = null;

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

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

            return(result);
        }