Exemplo n.º 1
0
        private Car Factory(JObject carObject)
        {
            string markKey = carObject["mark"].Value <string>();
            Car    newCar;

            switch (markKey)
            {
            case "Nissan":
                newCar = new Nissan();
                newCar.FillingFields(carObject);
                break;

            case "Audi":
                newCar = new Audi();
                newCar.FillingFields(carObject);
                break;

            case "Ford":
                newCar = new Ford();
                newCar.FillingFields(carObject);
                break;

            case "Hyndai":
                newCar = new Hyndai();
                newCar.FillingFields(carObject);
                break;

            default:
                newCar = null;
                break;
            }
            return(newCar);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ICar         car       = new Hyndai();
            CarDecorator decorator = new OfferPrice(car);

            Console.WriteLine(string.Format("Make : {0} , Price : {1} " + "DiscountPrice : {2}", decorator.Make, decorator.GetPrice().ToString(), decorator.GetDiscountedPrice().ToString()));
            Console.ReadLine();
        }