示例#1
0
        static void main(string[] args)
        {
            ILeiFengFactory factory = new UndergraduateFactory();

            LeiFeng student = factory.CreateLeiFeng();

            student.BuyRice();
            student.Sweep();
            student.Wash();
        }
示例#2
0
        static void main(string[] args)
        {
            LeiFeng studentA = SimpleFactory.CreateLeiFeng("Undergraduate");

            studentA.BuyRice();

            LeiFeng studentB = SimpleFactory.CreateLeiFeng("Undergraduate");

            studentB.Sweep();

            LeiFeng studentC = SimpleFactory.CreateLeiFeng("Undergraduate");

            studentC.Wash();
        }
示例#3
0
        public static LeiFeng CreateLeiFeng(string type)
        {
            LeiFeng result = null;

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

            case "Volunteer":
                result = new Volunteer();
                break;
            }

            return(result);
        }