private void AddHDD_button_Click(object sender, EventArgs e) { ILaptop tempLaptop = new HDD(laptopBeingEdited); laptopBeingEdited = tempLaptop; updatePurchaseInfo(laptopBeingEdited.GetProductDetails()); }
static async Task Main(string[] args) { ILaptop laptop = null; Console.WriteLine("1. Factory method - using interface..."); CaseInterface.IHPLaptopFactory interfaceFactory = null; interfaceFactory = new CaseInterface.EnvyHPLaptopFactory(); laptop = interfaceFactory.CreateHPLaptop(); Console.WriteLine(laptop.Description); Console.WriteLine("2. Factory method - using abstract class..."); CaseAbstractClass.HPLaptopFactory abstractFactory = null; abstractFactory = new CaseAbstractClass.PavilionHPLaptopFactory(); laptop = abstractFactory.MakeLaptop(); Console.WriteLine(laptop.Description); Console.WriteLine("3. Factory method - using private constructor..."); var laptop2 = LaptopPrivateConstructor.NewEnvyLaptop("2GH", 1); Console.WriteLine("4. Factory method - using asynchronous..."); LaptopAsynchronous laptop3 = await LaptopAsynchronous.NewEnvyLaptopAsync("2GH", 1); Console.WriteLine("5. Factory method - using inner class..."); var laptop4 = LaptopInnerClass.Factory.NewEnvyLaptop("2GH", 1); }
public void ProcesarCotizacion() { ILaptop laptop = null; IImpresora impresora = null; int diasEntrega = 0; decimal importe = 0M; switch (this.producto) { case "Laptop": laptop = this.tiendaProductos.GenerarInstanciaLaptop(); importe = laptop.CalcularImporte(this.cantidad); diasEntrega = laptop.ObtenerDiasEntrega(); break; case "Impresora": impresora = this.tiendaProductos.GenerarInstanciaImpresora(); importe = impresora.CalcularImporte(this.cantidad); diasEntrega = impresora.ObtenerDiasEntrega(); break; } this.imprimirMensaje(this.generarMensajeRequisicion(diasEntrega), this.generarMensajeCotizacion(importe)); }
public void AddingNegativeValueForChargeShouldDropCurrentCharge() { battery.Percentage = 100; laptop = new Laptop(motherboard, battery); laptop.ChargeBattery(-1); Assert.AreEqual(99, battery.Percentage); }
public void AddingNegativeValueBiggerThenCurrentValueShouldMakeCurrentChargeToZero() { battery.Percentage = 100; laptop = new Laptop(motherboard, battery); laptop.ChargeBattery(-101); Assert.AreEqual(0, battery.Percentage); }
public void AddingValueToCurrentValueShouldIncreaseCurrentCharge() { battery.Percentage = 50; laptop = new Laptop(motherboard, battery); laptop.ChargeBattery(10); Assert.AreEqual(60, battery.Percentage); }
public void ChargeShouldNeverBeBiggerThen100() { battery.Percentage = 50; laptop = new Laptop(motherboard, battery); laptop.ChargeBattery(60); Assert.AreEqual(100, battery.Percentage); }
public void AddingNUllPercentageShouldThrowReferenceNullExeption() { battery.Percentage = 50; laptop = new Laptop(motherboard, battery); laptop.ChargeBattery(60); Assert.AreEqual(100, battery.Percentage); }
public override ILaptop CreateLaptop() { var cpu = new Cpu64Bit(2); var harddrives = new[] { new HardDrive(500, false, 0) }; var ram = new Ram(4); var motherboard = new MotherBoard(cpu, ram, harddrives, this.colorfullVideoCard); this.laptop = new Laptop(motherboard, this.battery); return(this.laptop); }
private void Laptop_listBox_SelectedIndexChanged(object sender, EventArgs e) { if (Laptop_listBox.SelectedIndex >= 0 && Laptop_listBox.SelectedIndex <= laptopsBought.Count && laptopBeingEdited == null) { laptopBeingEdited = laptopsBought.ElementAt(Laptop_listBox.SelectedIndex); updatePurchaseInfo(laptopBeingEdited.GetProductDetails()); toggleGui(); re_edit_laptop = true; } }
string IVisitor.Visit(ILaptop e) { if (e is Lenove) return Visit((Lenove) e); if (e is Appel) return Visit((Appel) e); if (e is HP) return Visit((HP) e); return null; }
public override ILaptop CreateLaptop() { this.ram = new Ram(8); this.cpu = new Cpu32Bit(4); this.hardDrives = new[] { new HardDrive(1000, false, 0) }; var motherboard = new MotherBoard(this.cpu, this.ram, this.hardDrives, this.colorfullVideoCard); this.laptop = new Laptop(motherboard, new LaptopBattery()); return(this.laptop); }
public void Main() { ElectronicStoreClient e = new ElectronicStoreClient(); IDeviceFactory apple = e.CheckProducts(Manufacturers.APPLE); ILaptop macbookPro = apple.GetLaptop(); ISmartPhone smartPhone = apple.GetSmartPhone(); IDeviceFactory samsung = e.CheckProducts(Manufacturers.SAMSUNG); ILaptop galaxy = samsung.GetLaptop(); ISmartPhone notebook = samsung.GetSmartPhone(); }
public string Visit(ILaptop e) { if (e is Lenove) { return(Visit((Lenove)e)); } if (e is Appel) { return(Visit((Appel)e)); } if (e is HP) { return(Visit((HP)e)); } return(null); }
public void Execute(string[] splittedCommand, IPC pc, ILaptop laptop, IServer server) { var commandName = splittedCommand[0]; var commandArguments = int.Parse(splittedCommand[1]); if (commandName == "Charge") { laptop.ChargeBattery(commandArguments); } else if (commandName == "Process") { server.Process(commandArguments); } else if (commandName == "Play") { pc.Play(commandArguments); } }
//combo box private void metroComboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (metroComboBox1.SelectedIndex == 0) { laptop = new Appel(); pictureBox1.Image = LaptopStore.Properties.Resources.Apple; if (metroToggle1.Checked) { richTextBox1.Text = laptop.Accept(new DetailedDescription()); } else { richTextBox1.Text = laptop.Accept(new BriefDescription()); } } else if (metroComboBox1.SelectedIndex == 1) { laptop = new Lenove(); pictureBox1.Image = LaptopStore.Properties.Resources.Lenovo; if (metroToggle1.Checked) { richTextBox1.Text = laptop.Accept(new DetailedDescription()); } else { richTextBox1.Text = laptop.Accept(new BriefDescription()); } } else if (metroComboBox1.SelectedIndex == 2) { laptop = new HP(); pictureBox1.Image = LaptopStore.Properties.Resources.Hp; if (metroToggle1.Checked) { richTextBox1.Text = laptop.Accept(new DetailedDescription()); } else { richTextBox1.Text = laptop.Accept(new BriefDescription()); } } }
private void RemoveLaptop_button_Click(object sender, EventArgs e) { if (!re_edit_laptop) { toggleGui(); laptopBeingEdited = null; Info_label.Text = "0"; listbox_purchase_info.Items.Clear(); } else if (re_edit_laptop) { toggleGui(); laptopBeingEdited = null; Info_label.Text = "0"; laptopsBought.RemoveAt(Laptop_listBox.SelectedIndex); Laptop_listBox.Items.RemoveAt(Laptop_listBox.SelectedIndex); listbox_purchase_info.Items.Clear(); re_edit_laptop = false; } }
public static ILaptop fabrica(string laptop) { ILaptop interface1 = null; if (laptop == "MSI GL75") { interface1 = new MSI(); interface1.mostrar(); } if (laptop == "ASUS TUF Dash 15") { interface1 = new Asus(); interface1.mostrar(); } if (laptop == "Lenovo Legion 5") { interface1 = new Lenovo(); interface1.mostrar(); } return(interface1); }
private static void FactoryPatternSample() { Console.WriteLine("--Sample Factory Pattern--"); ILaptopCreator lc = new DellXpsConcreteCreator(); ILaptop l = lc.GetLaptop(""); Console.WriteLine("Selected laptop is " + l.GetName() + " with a price of " + l.GetPrice()); l = lc.GetLaptop("15"); Console.WriteLine("Selected laptop is " + l.GetName() + " with a price of " + l.GetPrice()); lc = new DellGSeriesConcreteCreator(); l = lc.GetLaptop(""); Console.WriteLine("Selected laptop is " + l.GetName() + " with a price of " + l.GetPrice()); l = lc.GetLaptop("5"); Console.WriteLine("Selected laptop is " + l.GetName() + " with a price of " + l.GetPrice()); lc = new DellVostroConcreteCreator(); l = lc.GetLaptop(""); Console.WriteLine("Selected laptop is " + l.GetName() + " with a price of " + l.GetPrice()); }
static void Main(string[] args) { Console.WriteLine("Enter a make - lenovo or dell"); String make = Console.ReadLine(); Console.WriteLine("Enter a budget"); int budget = Convert.ToInt32(Console.ReadLine()); //This singleton decides which factory to "fire up", based on the make (Dell, Lenovo etc.) that the customer requests FactoryCreatorSingleton myFactoryCreator = FactoryCreatorSingleton.GetInstance(); ILaptopFactory requestedMakeFactory = myFactoryCreator.GetLaptopFactory(make); //Here the appropriate factory will produce the laptop based on the budget ILaptop requestedLaptop = requestedMakeFactory.MakeLaptop(budget); //ILaptop myLaptop = ProductFactory.makeProduct(budget); Console.WriteLine("Creating a laptop from " + requestedMakeFactory.GetFactoryName() + " of make " + requestedLaptop.GetMake() + " \n" + " and model " + requestedLaptop.GetModel()); Console.ReadLine(); }
/// <summary> /// Shows all workplace equipment of the company. /// </summary> /// <param name="company">Company.</param> static void ShowWorkplaceEquipment(Company company) { IWorkplaceEquipmentFactory workplaceEquipmentFactory = WorkplaceEquipmentFactories.GetFactory(company); if (workplaceEquipmentFactory == null) { Console.WriteLine("{0} company did not provide any information about workplace equipments.\n", company); return; } Console.WriteLine("{0} workplace equipments:\n", company); IMouse mouse = workplaceEquipmentFactory.GetMouse(); Console.WriteLine(mouse); ILaptop laptop = workplaceEquipmentFactory.GetLaptop(); Console.WriteLine(laptop); ITablet tablet = workplaceEquipmentFactory.GetTablet(); Console.WriteLine(tablet); }
public KeyboardModDecorator(ILaptop laptop) : base(laptop) { }
public HDD(ILaptop Laptop) : base(Laptop) { name = "HDD"; price = 100; }
public LaptopDecorator(ILaptop Laptop) { this.laptop = Laptop; }
public USB(ILaptop Laptop) : base(Laptop) { name = "USB hub"; price = 10; }
public RAM(ILaptop Laptop) : base(Laptop) { name = "RAM"; price = 50; }
public void CreateLaptop(string model) { _laptop = _factory.CreateLaptop(model); }
public void SwitchOn(ILaptop obj) { LaptopAdaptor.ShowModel(obj); }
//combo box private void metroComboBox1_SelectedIndexChanged(object sender, EventArgs e) { if (metroComboBox1.SelectedIndex == 0) { laptop = new Appel(); pictureBox1.Image = LaptopStore.Properties.Resources.Apple; if (metroToggle1.Checked) richTextBox1.Text = laptop.Accept(new DetailedDescription()); else richTextBox1.Text = laptop.Accept(new BriefDescription()); } else if (metroComboBox1.SelectedIndex == 1) { laptop = new Lenove(); pictureBox1.Image = LaptopStore.Properties.Resources.Lenovo; if (metroToggle1.Checked) richTextBox1.Text = laptop.Accept(new DetailedDescription()); else richTextBox1.Text = laptop.Accept(new BriefDescription()); } else if (metroComboBox1.SelectedIndex == 2) { laptop = new HP(); pictureBox1.Image = LaptopStore.Properties.Resources.Hp; if (metroToggle1.Checked) richTextBox1.Text = laptop.Accept(new DetailedDescription()); else richTextBox1.Text = laptop.Accept(new BriefDescription()); } }
public PortableLaptopDecorator(ILaptop iLaptop) { this.iLaptop = iLaptop; }
public static void ShowModel(ILaptop obj) { obj.ShowModel(); }
public SoundModDecorator(ILaptop laptop) : base(laptop) { }
public GPU(ILaptop Laptop) : base(Laptop) { name = "GPU"; price = 200; }