Exemple #1
0
        /// <summary>
        /// The method creates a swift car as desired by the consumer
        /// </summary>
        /// <param name="carType"> the car type specified by the Consumer</param>
        /// <param name="carColor"> the color  of the car specified by the consumer </param>
        /// <returns> the desired swift car</returns>
        public static SwiftCar CreateSwiftCar(SwiftCarType carType, CarColor carColor)
        {
            SwiftCar car = null;

            switch (carType)
            {
            case SwiftCarType.BASIC:
                car = new SwiftCarBasic(carColor);
                break;

            case SwiftCarType.FEATURED:
                car = new SwiftCarFeatured(carColor);
                break;
            }
            return(car);
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            //the basic Swift car of Blue color -Creation
            SwiftCar BlueBasicSwiftCar = SwiftCarFactory.CreateSwiftCar(SwiftCarType.BASIC, CarColor.BLUE);

            //Computation of Price
            float BlueBasicSwiftCarPrice = BlueBasicSwiftCar.CaliculatePrice();

            Console.WriteLine("price of Blue Basic Swift car" + BlueBasicSwiftCarPrice);

            //the Red Featured Swift car of Blue color -Creation
            SwiftCar RedFeaturedSwiftCar = SwiftCarFactory.CreateSwiftCar(SwiftCarType.FEATURED, CarColor.RED);

            // Computation of Price
            float RedFeaturedSwiftCarPrice = RedFeaturedSwiftCar.CaliculatePrice();

            Console.WriteLine("price of  Red Featured Swift car" + RedFeaturedSwiftCarPrice);
        }