public static void Run()
        {
            VehicleDTO vehicle = new VehicleDTO();
            vehicle.VIN = "12345";
            vehicle.Make = "Maruti";
            vehicle.Model = "Ritz ZXi";
            vehicle.Name = "Maruti Suzuki Ritz 2014 Model";
            vehicle.Year = "2014";
            vehicle.Type = VehicleType.Car;


            Shop shop = new Shop();

            CarBuilder carBuilder = new CarBuilder(vehicle);

            shop.Contruct(carBuilder);


            vehicle.Type = VehicleType.Truck;
            TruckBuilder truckBuilder = new TruckBuilder(vehicle);

            shop.Contruct(truckBuilder);


            vehicle.Type = VehicleType.Bike;
            BikeBuilder bikeBuilder = new BikeBuilder(vehicle);

            shop.Contruct(bikeBuilder);


            Console.ReadKey();
        }
Exemplo n.º 2
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var carBuilder = new CarBuilder();
            var car        = new VehicleCreator(carBuilder);

            car.CreateVehicleCaracteristics();
            Console.WriteLine(carBuilder.ToString());

            car.CreateVehicleAcessories();
            Console.WriteLine(carBuilder.ToString());

            //alternativa
            var truckBuilder = new TruckBuilder()
                               .SetModel("FH-420")
                               .SetColor("Black")
                               .SetYear(2020);

            Console.WriteLine(truckBuilder.ToString());

            truckBuilder.SetAcessories(new List <string> {
                "Geladeira", "Capa para bancos", "Alarme"
            });
            Console.WriteLine(truckBuilder.ToString());

            Console.ReadKey();
        }
        public void TestTruckBuilder()
        {
            AutomobileBuilder  builder  = new TruckBuilder();
            AutomobileDirector director = new AutomobileDirector(builder);

            director.Construct();
            var parts = builder.GetResult().ShowParts();

            Assert.IsTrue(parts.Contains("Big Lift Kit"));
            Assert.IsTrue(parts.Contains("Big Loud Engine"));
        }
Exemplo n.º 4
0
 static void Main(string[] args)
 {
     Vehicle[] vehiclesArray = new Vehicle[3];
     Car[]     carsArray     = new Car[3];
     Truck[]   trucksArray   = new Truck[3];
     Bus[]     busesArray    = new Bus[3];
     System.Console.WriteLine("Filling vehicle arrays with random values\n");
     for (int i = 0; i < vehiclesArray.Length; ++i)
     {
         vehiclesArray[i] = new VehicleBuilder().BuildFuelTankCapacity(i * 10).BuildFuelConsumption(i).BuildName("VehicleNikolai" + i).GetResult();
         carsArray[i]     = new CarBuilder().BuildCoachbuileder((Coachbuilder)(i % 5)).BuildFuelTankCapacity((i + 5) * new System.Random().Next(1, i + 5)).BuildFuelConsumption(i).BuildName("CarNikolai" + i).BuildPassengersCapacity(10).BuildNumberOfPassengers(i).GetResult();
         trucksArray[i]   = new TruckBuilder().BuildCarryingCapacity(i * 2).BuildCargoWeight(i).BuildFuelTankCapacity(i).BuildFuelConsumption(i).BuildName("TruckNikolai" + i).GetResult();
         busesArray[i]    = new BusBuilder().BuildFuelTankCapacity(i * 10).BuildFuelConsumption(i).BuildName("BusNikolai" + i).BuildPassengersCapacity(i * 10).BuildNumberOfPassengers(i).GetResult();
     }
     foreach (Vehicle vehicle in vehiclesArray)
     {
         System.Console.WriteLine("vehicle.Name:\t" + vehicle.Name);
         System.Console.WriteLine("vehicle.FuelTankCapacity:\t" + vehicle.FuelTankCapacity);
         System.Console.WriteLine("vehicle.FuelConsumption:\t" + vehicle.FuelConsumption);
     }
     System.Console.WriteLine();
     foreach (Car car in carsArray)
     {
         System.Console.WriteLine("car.Name:\t" + car.Name);
         System.Console.WriteLine("car.FuelTankCapacity:\t" + car.FuelTankCapacity);
         System.Console.WriteLine("car.FuelConsumption:\t" + car.FuelConsumption);
         System.Console.WriteLine("car.NumberOfPassengers:\t" + car.NumberOfPassengers);
         System.Console.WriteLine("car.PassengersCapacity:\t" + car.PassengersCapacity);
         System.Console.WriteLine("car.GetMaximumDistance:\t" + car.GetMaximumDistance);
         System.Console.WriteLine("car.FuelConsumption:\t" + car.FuelConsumption);
     }
     System.Console.WriteLine();
     foreach (Truck truck in trucksArray)
     {
         System.Console.WriteLine("truck.Name:\t" + truck.Name);
         System.Console.WriteLine("truck.Name:\t" + truck.FuelTankCapacity);
         System.Console.WriteLine("truck.FuelConsumption:\t" + truck.FuelConsumption);
         System.Console.WriteLine("truck.CargoWeight:\t" + truck.CargoWeight);
         System.Console.WriteLine("truck.CarryingCapacity:\t" + truck.CarryingCapacity);
     }
     System.Console.WriteLine();
     foreach (Bus bus in busesArray)
     {
         System.Console.WriteLine("bus.Name:\t" + bus.Name);
         System.Console.WriteLine("bus.FuelTankCapacity:\t" + bus.FuelTankCapacity);
         System.Console.WriteLine("bus.FuelConsumption:\t" + bus.FuelConsumption);
         System.Console.WriteLine("bus.NumberOfPassengers:\t" + bus.NumberOfPassengers);
         System.Console.WriteLine("bus.PassengersCapacity):\t" + bus.PassengersCapacity);
     }
 }
    void Start()
    {
        Shop director = new Shop();

        var carBuilder   = new CarBuilder();
        var truckBuilder = new TruckBuilder();

        director.Construct(carBuilder);
        director.Construct(truckBuilder);

        var car     = carBuilder.GetVehicle();
        var bicycle = truckBuilder.GetVehicle();

        Debug.Log("<color=red>Car Parts</color>");
        car.PrintParts();
        Debug.Log("<color=blue>Truck Parts</color>");
        bicycle.PrintParts();
    }
Exemplo n.º 6
0
        /// <summary>
        /// Provides an <see cref="IVehicleBuilder"/> appropriate for the requested <see cref="VehicleType"/>.
        /// </summary>
        /// <param name="carType">A <see cref="VehicleType"/>.</param>
        /// <returns>A <see cref="IVehicleBuilder"/>.</returns>
        public static IVehicleBuilder GetBuilder(VehicleType carType)
        {
            IVehicleBuilder builder = null;

            switch (carType)
            {
            case VehicleType.Convertible:
                builder = new ConvertibleBuilder();
                break;

            case VehicleType.Sedan:
                builder = new SedanBuilder();
                break;

            case VehicleType.Truck:
                builder = new TruckBuilder();
                break;
            }

            return(builder);
        }
Exemplo n.º 7
0
 public TruckTests()
 {
     _truckBuilder   = new TruckBuilder();
     _trailerBuilder = new TrailerBuilder();
 }