Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var car1 = CarConstructor.Construct(new Engine("diesel"), new Color("blue"), new Transmission("manual"));

            Console.WriteLine(car1);
            car1 = CarConstructor.Reconstruct(car1, new Engine("1D12"));
            Console.WriteLine(car1);

            Console.ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            CarConstructor.Car car = CarConstructor.Construct(new Transmission(Transmission.TransmissionType.Automatic),
                                                              new Color(Color.ColorValue.Green),
                                                              new Engine(Engine.EngineType.Gasoline));
            // Replace the engine with a diesel engine
            CarConstructor.ReConstruct(car, new Engine(Engine.EngineType.Diesel));

            Console.WriteLine(car);
            Console.ReadKey();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var car1 = CarConstructor.Construct(Color.black, Engine.М_271, Transmission.mechanics);

            Console.WriteLine("Car1: " + car1.color.ToString() + ", " + car1.engine.ToString() + ", " + car1.transmission.ToString());
            car1 = CarConstructor.Reconstruct(car1, Engine.М_272);

            Console.WriteLine("Car1: " + car1.color.ToString() + ", " + car1.engine.ToString() + ", " + car1.transmission.ToString());
            car1 = CarConstructor.Reconstruct(car1, Color.red, Engine.ОМ_611);

            Console.WriteLine("Car1: " + car1.color.ToString() + ", " + car1.engine.ToString() + ", " + car1.transmission.ToString());
            Console.ReadKey();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var car1          = CarConstructor.Construct("blue", "v8", "mechanics");
            var engine1       = new Engine("v6");
            var color1        = new Color("green");
            var transmission1 = new Transmission("auto");
            var car2          = CarConstructor.Construct(color1, engine1, transmission1);

            Console.WriteLine("Car1: " + car1.color.color + ", " + car1.engine.engineName + ", " + car1.transmission.transmission);
            Console.WriteLine("Car2: " + car2.color.color + ", " + car2.engine.engineName + ", " + car2.transmission.transmission);

            car1 = CarConstructor.Reconstruct(car1, "v4 turbo");
            Console.WriteLine("Car1: " + car1.color.color + ", " + car1.engine.engineName + ", " + car1.transmission.transmission);
            car2 = CarConstructor.Reconstruct(car2, engine1);
            Console.WriteLine("Car2: " + car2.color.color + ", " + car2.engine.engineName + ", " + car2.transmission.transmission);

            Console.ReadKey();
        }