Ejemplo n.º 1
0
    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();
    }
Ejemplo n.º 2
0
 public ComputerRepository()
 {
     _laptopBuilder              = new LaptopBuilder();
     _laptopBuildDirector        = new LaptopBuildDirector(_laptopBuilder);
     _superComputerBuilder       = new SuperComputerBuilder();
     _superComputerBuildDirector = new SuperComputerBuildDirector(_superComputerBuilder);
 }
Ejemplo n.º 3
0
    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");
        }
Ejemplo n.º 6
0
        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");
        }
Ejemplo n.º 7
0
        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"));
        }
Ejemplo n.º 8
0
        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"));
        }
Ejemplo n.º 10
0
 public void SetLaptopBuilder(LaptopBuilder lBuilder)
 {
     _laptopBuilder = lBuilder;
 }
Ejemplo n.º 11
0
 public LaptopBuyer(LaptopBuilder laptopBuilder)
 {
     _laptopBuilder = laptopBuilder;
 }
Ejemplo n.º 12
0
 public void SetLaptopBuilder(LaptopBuilder laptopBuilder)
 {
     this.laptopBuilder = laptopBuilder;
 }
Ejemplo n.º 13
0
 public void CreateLaptopBuilder(LaptopBuilder lBuilder)
 {
     _lBuilder = lBuilder;
 }
Ejemplo n.º 14
0
 public void SetLaptopBuilder(LaptopBuilder lBuilder)
 {
     _laptopBuilder = lBuilder;
 }
Ejemplo n.º 15
0
 public void Create(LaptopBuilder laptopBuilder)
 {
     laptopBuilder.CombineRam();
     laptopBuilder.CombineDisk();
 }
Ejemplo n.º 16
0
 public TestLaptopBuilder()
 {
     _laptopBuilder       = new LaptopBuilder();
     _laptopBuildDirector = new LaptopBuildDirector(_laptopBuilder);
 }