예제 #1
0
        public void UseCar()
        {
            carenum carenum = (carenum)(Enum.Parse(typeof(carenum), cartype));

            IRunable runable = null;

            switch (carenum)
            {
            case carenum.aodi:
                runable = new Aodi();
                break;

            case carenum.baoma:
                runable = new BaoMa();
                break;

            case carenum.benchi:
                runable = new Benchi();
                break;

            default:
                break;
            }
            runable.GuaDang();
            runable.Run();
        }
예제 #2
0
        /// <summary>
        /// 简单工厂-基础实现r
        /// </summary>
        /// <param name="carenum"></param>
        public void UseCar(carenum carenum)
        {
            IRunable runable = null;

            switch (carenum)
            {
            case carenum.aodi:
                runable = new Aodi();
                break;

            case carenum.baoma:
                runable = new BaoMa();
                break;

            case carenum.benchi:
                runable = new Benchi();
                break;

            default:
                break;
            }
            runable.GuaDang();
            runable.Run();
        }