Example #1
0
        public static Nightingale CreatNightingale(string type)
        {
            Nightingale resule = null;

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

            case "社區義工":
                resule = new Volunteer();
                break;
            }
            return(resule);
        }
Example #2
0
        static void Main(string[] args)
        {
            IFactory    factory = new UndergraduateFactory();
            Nightingale student = factory.CreatNightingale();

            Nightingale volunteer = factory.CreatNightingale();

            student.BuyRice();
            student.Sweep();
            student.Wash();

            volunteer.BuyRice();
            volunteer.Sweep();
            volunteer.Wash();

            Console.Read();
        }