Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            string whatToMake = "van"; // or "van"
            AbstractVehicleFactory factory = null;

            // Create the correct 'factory'...
            if (whatToMake.Equals("car"))
            {
                factory = new CarFactory();
            }
            else
            {
                factory = new VanFactory();
            }

            // Create the vehicle parts, either a car or a van...
            IBody vehicleBody = factory.CreateBody();
            IChassis vehicleChassis = factory.CreateChassis();
            IGlassware vehicleGlassware = factory.CreateGlassware();

            // See what we've created...
            Console.WriteLine(vehicleBody.BodyParts);
            Console.WriteLine(vehicleChassis.ChassisParts);
            Console.WriteLine(vehicleGlassware.GlasswareParts);

            Console.Read();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            VehicleFactory <Car>        carFactory = new CarFactory();
            VehicleFactory <Motorcycle> mcFactory  = new MotorcycleFactory();

            var cars = new List <Car>
            {
                carFactory.GetVehicle(nameof(Mazda)),
                carFactory.GetVehicle(nameof(Passat)),
                carFactory.GetVehicle(nameof(Toledo))
            };

            var motocycles = new List <Motorcycle>
            {
                mcFactory.GetVehicle(nameof(Yamaha)),
                mcFactory.GetVehicle(nameof(Honda)),
                mcFactory.GetVehicle(nameof(Ducati))
            };

            foreach (var car in cars)
            {
                Console.WriteLine($"{car.Name} has {car.HorsePowers} HP.");
            }

            foreach (var mc in motocycles)
            {
                Console.WriteLine($"{mc.Name} has {mc.HorsePowers} HP.");
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            string whatToMake = "car"; // or "van"

            AbstractVehicleFactory factory = null;

            if (whatToMake.Equals("car"))
            {
                factory = new CarFactory();
            }
            else
            {
                factory = new VanFactory();
            }

            // Create the vehicle's component parts...
            // These will either be all car parts or all van parts
            IBody      vehicleBody    = factory.CreateBody();
            IChassis   vehicleChassis = factory.CreateChassis();
            IGlassware vehicleWindows = factory.CreateGlassware();

            // Show what we've created...
            Console.WriteLine(vehicleBody.BodyParts);
            Console.WriteLine(vehicleChassis.ChassisParts);
            Console.WriteLine(vehicleWindows.GlasswareParts);
            Console.Read();
        }
Ejemplo n.º 4
0
        public Driver(CarFactory carFactory)
        {
            if (carFactory == null)
            {
                throw new ArgumentNullException(nameof(carFactory));
            }

            _sportsCar = carFactory.CreateSportsCar();
            _familyCar = carFactory.CreateFamilyCar();
        }
Ejemplo n.º 5
0
        static void Main()
        {
            CarFactory myCarFactory = AudiFactory.instance;
            Client     client1      = new Client(myCarFactory);

            Console.WriteLine("Макс. скорость {0} {2}: {1} км/ч"
                              , client1.getCarName(), client1.runMaxSpeed(), client1.getCarBody());

            Console.ReadLine();
        }
Ejemplo n.º 6
0
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());
            CarFactory factory = CarShowRoom.GetCar("Maruthi");
            var        car     = factory.CreateFamilyCar();

            car.Speed();
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            CarFactory ford_car = new FordFactory();
            Client     c1       = new Client(ford_car);

            Console.WriteLine("Максимальная скорость {0} составляет {1} км/час", c1.ToString(), c1.RunMaxSpeed());

            CarFactory audi_car = AudiFactory.MyAudiFactory;
            Client     c2       = new Client(audi_car);

            Console.WriteLine("Максимальная скорость {0} составляет {1} км/час", c2.ToString(), c2.RunMaxSpeed());
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            CarFactory ford_car = new FordFactory();
            Client     c1       = new Client(ford_car);

            Console.WriteLine("Shape: {0}    Max speed {1} is {2} km/h", c1.ShapeAuto(), c1.ToString(), c1.RunMaxSpeed());

            CarFactory audi_car = AudiFactory.getAudiFactory();
            Client     c2       = new Client(audi_car);

            Console.WriteLine("Shape: {0}    Max speed {1} is {2} km/h ", c2.ShapeAuto(), c2.ToString(), c2.RunMaxSpeed());
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            AbstractFactory carFactory = new CarFactory();
            AbstractCar     car        = carFactory.CreateProduct();

            car.Run();

            AbstractFactory busFactory = new BusFactory();
            AbstractCar     bus        = busFactory.CreateProduct();

            bus.Run();

            Console.Read();
        }
Ejemplo n.º 10
0
        public static Car MountCar(string type)
        {
            CarFactory carFactory = null;

            switch (type)
            {
            case "regular":
                carFactory = new RegularCarFactory();
                break;

            case "sporting":
                carFactory = new SportingCarFactory();
                break;
            }

            Car car = new Car();

            car.Color  = carFactory.Paint();
            car.Engine = carFactory.InstallEngine();

            return(car);
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            string whatToMake = "car";
            AbstractVehicleFactory factory = null;

            if (whatToMake.Equals("car"))
            {
                factory = new CarFactory();
            }
            else
            {
                factory = new VanFactory();
            }

            IBody      vehicleBody      = factory.CreateBody();
            IChassis   vehicleChassis   = factory.CreateChassis();
            IGlassware vehicleGlassware = factory.CreateGlassware();

            Console.WriteLine(vehicleBody.BodyParts);
            Console.WriteLine(vehicleChassis.ChassisParts);
            Console.WriteLine(vehicleGlassware.GlasswarePart);
            Console.ReadKey();
        }
Ejemplo n.º 12
0
 public Client(CarFactory car_factory)
 {
     abstractCar    = car_factory.CreateCar();
     abstractEngine = car_factory.CreateEngine();
     abstractshape  = car_factory.CreateShape();
 }
Ejemplo n.º 13
0
 public Client(CarFactory car_factory)
 {
     abstractCar    = car_factory.CreateCar();
     abstractEngine = car_factory.CreateEngine();
     abstractBody   = car_factory.CreateBody();
 }
Ejemplo n.º 14
0
 public Client(CarFactory car_factory)
 {
     abstractCar    = car_factory.CreateCar();
     abstractEngine = car_factory.CreateEngine();
     abstractkuzov  = car_factory.CreateKuzov();
 }
Ejemplo n.º 15
0
 private (SUV, Sedan) CreateCars(CarFactory factory)
 => (factory.CreateSUV(), factory.CreateSedan());
Ejemplo n.º 16
0
 static void Main(string[] args)
 {
     AbstractCarFactory carFactory = new CarFactory();
     ICar economy = carFactory.GetCar("economy");
     ICar premium = carFactory.GetCar("premium");
 }
Ejemplo n.º 17
0
 public CarManager(CarFactory carFactory)
 {
     //_carFactory = carFactory;
     _car = carFactory.CarCreator();
 }
Ejemplo n.º 18
0
 public CarsCreation(CarFactory factory)
 {
     this.luxuryCar = factory.CreatelLuxuryCar();
     this.sportCar  = factory.CreatesSportsCar();
     this.jeepCar   = factory.CreateJeepCar();
 }
Ejemplo n.º 19
0
 public Driver(CarFactory carFactory)
 {
     _sportsCar = carFactory.CreateSportsCar();
     _familyCar = carFactory.CreateFamilyCar();
 }