static void Main(string[] args) { // client code ElectornicsManufacture em = new ElectornicsManufacture(); // builds phones CellPhoneBuilder builder = new CellPhoneBuilder(); em.set_builder(builder); em.build_iphone(); CellPhone iPhone = (CellPhone)em.get_product(); iPhone.use_phone(); em.build_samsung_note(); CellPhone note = (CellPhone)em.get_product(); note.use_phone(); // builds laptops LaptopBuilder builder2 = new LaptopBuilder(); em.set_builder(builder2); em.build_thinkpad(); Laptop tp = (Laptop)em.get_product(); tp.use_laptop(); }
public ComputerRepository() { _laptopBuilder = new LaptopBuilder(); _laptopBuildDirector = new LaptopBuildDirector(_laptopBuilder); _superComputerBuilder = new SuperComputerBuilder(); _superComputerBuildDirector = new SuperComputerBuildDirector(_superComputerBuilder); }
static void Main(string[] args) { Console.WriteLine("------------"); AppleBuilder computerBuilder = new AppleBuilder(); ComputerShop computerShop = new ComputerShop(); computerShop.ConstructComputer(computerBuilder); computerBuilder.Computer.DisplayConfiguration(); Console.WriteLine("------------"); LaptopBuilder laptopBuilder = new LaptopBuilder(); ComputerShop laptopShop = new ComputerShop(); laptopShop.ConstructComputer(laptopBuilder); laptopBuilder.Computer.DisplayConfiguration(); Console.WriteLine("------------"); DesktopBuilder desktopBuilder = new DesktopBuilder(); ComputerShop desktopShop = new ComputerShop(); desktopShop.ConstructComputer(desktopBuilder); desktopBuilder.Computer.DisplayConfiguration(); Console.ReadLine(); LaptopBuilder laptopBuilder = new LaptopBuilder(); ComputerShop laptopShop = new ComputerShop(); laptopShop.ConstructComputer(laptopBuilder); laptopBuilder.Computer.DisplayConfiguration(); }
public void ConstructAcerLaptop_ShouldReturnAnAcerLaptop() { var laptopFactory = new LaptopFactory(); LaptopBuilder acerLaptopBuilder = laptopFactory.ConstructAcerLaptop(); Assert.IsNotNull(acerLaptopBuilder); StringAssert.Contains(acerLaptopBuilder.ToString(), "Acer"); }
public void ConstructLenovoLaptop_ShouldReturnAnLenovoLaptop() { var laptopFactory = new LaptopFactory(); LaptopBuilder lenovoLaptopBuilder = laptopFactory.ConstructLenovoLaptop(); Assert.IsNotNull(lenovoLaptopBuilder); StringAssert.Contains(lenovoLaptopBuilder.ToString(), "Lenovo"); }
public void WhenBuildingALaptop_AndRngChoosesTheCorrectBoard_AllPartsAreAssembledProperly() { ComputerBuilder technician = new LaptopBuilder(); _workshop.Assemble(technician); var contents = technician.Computer.LookInside(); Assert.True(contents["processor"] == "Intel Core Duo"); Assert.True(contents["storage"] == "5400 RPM HDD"); Assert.True(contents["memory"] == "Williams-Kilburn Tube Array"); Assert.True(contents["cooling"] == "Single Small Fan"); }
public ActionResult BuildLaptop(FormCollection collection) { Employee employee = db.Employees.Find(Convert.ToInt32(collection["Id"])); ISystemBuilder systemBuilder = new LaptopBuilder(); Director.ConfigurationBuilder configurationBuilder = new Director.ConfigurationBuilder(); configurationBuilder.BuildSystem(systemBuilder, collection); ComputerSystem computerSystem = systemBuilder.GetSystem(); employee.SystemConfigurationDetails = string.Format("RAM: {0},HDDSize: {1},TouchScreen: {2}", computerSystem.RAM, computerSystem.HDDSize, computerSystem.TouchScreen); db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
static void Main(string[] args) { //create SysAdmin object SysAdmin sysadmin = new SysAdmin(); //create PC object ComputerBuilder cbuilder = new PCBuilder(); //build new PC Computer pc = sysadmin.build(cbuilder); Console.WriteLine("Building PC \n"); Console.WriteLine(pc.ToString()); //build new Laptop cbuilder = new LaptopBuilder(); Computer laptop = sysadmin.build(cbuilder); Console.WriteLine("Building Laptop \n"); Console.WriteLine(laptop.ToString()); }
public ActionResult BuildLaptop(FormCollection formCollection) { //step 1 Employee employee = db.Employees.Find(Convert.ToInt32(formCollection["employeeID"])); //step 2 concrete builder ISystemBuilder systemBuilder = new LaptopBuilder(); //step 3 Director ConfigurationBuilder builder = new ConfigurationBuilder(); builder.BuildSystem(systemBuilder, formCollection); //step 4 return the system ComputerSystem system = systemBuilder.GetSystem(); employee.SystemConfigurationDetails = string.Format("RAM:{0},HDDSize:{1},TouchScreen:{2}" , system.RAM, system.HDDSize, system.TouchScreen); db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public void SetLaptopBuilder(LaptopBuilder lBuilder) { _laptopBuilder = lBuilder; }
public LaptopBuyer(LaptopBuilder laptopBuilder) { _laptopBuilder = laptopBuilder; }
public void SetLaptopBuilder(LaptopBuilder laptopBuilder) { this.laptopBuilder = laptopBuilder; }
public void CreateLaptopBuilder(LaptopBuilder lBuilder) { _lBuilder = lBuilder; }
public void Create(LaptopBuilder laptopBuilder) { laptopBuilder.CombineRam(); laptopBuilder.CombineDisk(); }
public TestLaptopBuilder() { _laptopBuilder = new LaptopBuilder(); _laptopBuildDirector = new LaptopBuildDirector(_laptopBuilder); }