public void Work() { Console.WriteLine("Test car factory with differences properties " + "but equal count of properties:"); ICarBuilder cheapCarBuilder = new CheapCarBuilder(); ICarDirector carDirector = new CarDirector(cheapCarBuilder); carDirector.CreateCar(); Console.WriteLine(cheapCarBuilder.GetProduct().CarDescription()); Console.WriteLine(); ICarBuilder expensiveCarBuilder = new ExpensiveCarBuilder(); carDirector.ChangeBuilder(expensiveCarBuilder); carDirector.CreateCar(); Console.WriteLine(expensiveCarBuilder.GetProduct().CarDescription()); Console.WriteLine(); ITeaBuilder usualTeaBuilder = new UsualTeaBulder(); ITeaDirector teaMaker = new TeaDirector(usualTeaBuilder); teaMaker.MakeTea(); Console.WriteLine("Usual tea"); Console.WriteLine(usualTeaBuilder.GetTea().DescribeTea()); ITeaBuilder tastyTeaBuilder = new TastyTeaBuilder(); teaMaker.ChangeBuilder(tastyTeaBuilder); teaMaker.MakeTea(); Console.WriteLine("Tasty tea"); Console.WriteLine(tastyTeaBuilder.GetTea().DescribeTea()); }
public void CarBuilderPatternTest() { AbstractCar car = new Saloon(new StandardEngine(1300)); VehicleBuilder builder = new CarBuilder(car); VehicleDirector vehicleDirector = new CarDirector(); IVehicle veh = vehicleDirector.Build(builder); Console.WriteLine(veh); }
static void Main(string[] args) { CarDirector carDirector = new CarDirector(); ICarBuilder smallCarBuilder = new SmallCarBuilder(); // buduj według logiki CarDirector używając implementacji z SmallCarBuilder carDirector.ConstructCar(smallCarBuilder); Car smallCar = smallCarBuilder.GetResult(); }
public Sample() { //Sample for Saloon AbstractCar car = new Saloon(new StandardEngine(1300)); VehicleBuilder builder = new CarBuilder(car); VehicleDirector director = new CarDirector(); IVehicle v = director.Build(builder); Console.WriteLine(v); }
static void Main() { /* * - Builder class contains all possible build methods for all possible * vehicle types. */ AbstractCar vCar = new Saloon(new StandardEngine(1300)); VehicleBuilder vBuilder = new CarBuilder(vCar); VehicleDirector vDirector = new CarDirector(); Common.IVehicle vVehicle = vDirector.Build(vBuilder); WriteLine(vVehicle); ReadKey(); }
public void Test() { builder = new BenzBuilder(); director = new CarDirector(builder); director.CreateCar(); builder = new BmwBuilder(); director = new CarDirector(builder); director.CreateCar(); builder = new HondaBuilder(); director = new CarDirector(builder); director.CreateCar(); }
public void DisplayExample() { var builder = new CarBuilder(); var director = new CarDirector(builder); director.BuildCheapCar(); builder.GetResult().DisplayOptions(); Console.WriteLine(); director.BuildSportsCar(); builder.GetResult().DisplayOptions(); }
public static void Main(string[] args) { CarBuilder carBuilder = new SedanCarBuilder(); CarDirector director = new CarDirector(carBuilder); director.Build(); Car car = carBuilder.getCar(); carBuilder = new SportsCarBuilder(); director = new CarDirector(carBuilder); director.Build(); car = carBuilder.getCar(); Form form = new Form.FormBuilder("Dave", "Carter", "DavCarter", "DAvCaEr123 - ").PasswordHint("MyName").City("NY").Language("English").build(); }
static void Main(string[] args) { List <Car> taxistaxiStation = new List <Car>(); CarDirector director = new CarDirector(); BasicEquipmentCarBuilder basicEquipmentCarBuilder = new BasicEquipmentCarBuilder(); ComfortableEquipmentCarBuilder comfortableEquipmentCarBuilder = new ComfortableEquipmentCarBuilder(); VIPCarBuilder vipCarBuilder = new VIPCarBuilder(); director.SetBuilder(basicEquipmentCarBuilder); director.ConstructCar(Brand.Toyota, "Camry", Carcass.Hatchback, 10500, 220, 10); taxistaxiStation.Add(basicEquipmentCarBuilder.GetCar()); director.ConstructCar(Brand.Volkswagen, "Golf 5", Carcass.Sedan, 8200, 210, 8); taxistaxiStation.Add(basicEquipmentCarBuilder.GetCar()); director.SetBuilder(comfortableEquipmentCarBuilder); director.ConstructCar(Brand.BMW, "X5", Carcass.Crossover, 25300, 250, 15); taxistaxiStation.Add(comfortableEquipmentCarBuilder.GetCar()); director.ConstructCar(Brand.Volvo, "s90", Carcass.Hatchback, 21800, 260, 12); taxistaxiStation.Add(comfortableEquipmentCarBuilder.GetCar()); director.SetBuilder(vipCarBuilder); director.ConstructCar(Brand.RollsRoyce, "PHANTOM", Carcass.Limousine, 60000, 150, 20); taxistaxiStation.Add(vipCarBuilder.GetCar()); Console.WriteLine("Calculation of the total cost of car taxis. "); long carsCost = Autopark.CalculateAutoparkCost(taxistaxiStation); Console.WriteLine($"Autopark total cost is: {carsCost}$"); Console.WriteLine(); Console.WriteLine("Sorting cars by fuel consumption."); List <Car> sortedListByFuelConsumption = Autopark.SortCarsByFuelConsumption(taxistaxiStation); foreach (var car in sortedListByFuelConsumption) { Console.WriteLine($"{car} - {car.FuelConsumption} liters"); } Console.WriteLine(); Console.WriteLine("Searching cars by speed:"); List <Car> carsBySpeed = Autopark.SearchCarsBySpeed(taxistaxiStation, 150, 250); if (carsBySpeed.Count == 0) { Console.WriteLine("There are no cars with defined maximum speed"); } else { foreach (Car car in carsBySpeed) { Console.WriteLine(car); } } Console.ReadKey(); }