Ejemplo n.º 1
0
        static public ICarDealerTask CreateCarDeal(string car_name)
        {
            ICarDealerTask carObj = null;

            switch (car_name)
            {
            case "Ford":
                carObj = new Ford();
                break;

            case "Toyota":
                carObj = new Toyota();
                break;

            case "Nissan":
                carObj = new Nissan();
                break;

            default:
                carObj = new Ford();
                break;
            }

            return(carObj);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            ICarDealerTask task = null;

            Console.WriteLine("Enter car name:");
            string car_name = Console.ReadLine().ToString();

            task = CarFactory.CreateCarDeal(car_name);

            task.SignContract();
            task.ConfirmTransaction();
            task.DeliverCar();

            Console.WriteLine(car_name + " is sold.");

            Console.ReadLine();
        }