Example #1
0
        static void Main(string[] args)
        {
            IFactory    factory = new UndergraduateFactory();
            Nightingale personA = factory.CreateNightingale();
            Nightingale personB = factory.CreateNightingale();
            Nightingale personC = factory.CreateNightingale();

            personA.Sweep();
            personB.Wash();
            personC.BuyRice();

            Console.ReadLine();
        }
Example #2
0
        public static Nightingale CreateNightingale(string type)
        {
            Nightingale result = null;

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

            case "社區義工":
                result = new Volunteer();
                break;
            }

            return(result);
        }