static void Main(string[] args) { Laptop hp1 = new Hp(); Laptop dell1 = new Dell(); hp1.TurnOn(); dell1.TurnOn(); }
protected override IDeviceType GetDeviceType(EmployeePositionType employeePosition) { var dell = new Dell(); if (employeePosition == EmployeePositionType.TeamManager) { return(dell.GetDeviceType("Dell", DeviceType.Laptop)); } return(dell.GetDeviceType("Dell", DeviceType.Desktop)); }
public static void Test() { IBM ibm = new IBM(); ibm.Show(); Dell dell = new Dell(); dell.Show(); }
static void Main(string[] args) { Laptop hp = new Hp(); Laptop dell = new Dell(); hp.TurnOn(); hp.TurnOn(true); dell.TurnOn(); dell.TurnOn(false); }
static void Main(string[] args) { Hp hp = new Hp(); Dell dell = new Dell(); hp.TurnOn(); Console.WriteLine(hp.TouchScreen); hp.TurnOff(); dell.TurnOn(); Console.WriteLine(dell.TouchScreen); dell.TurnOff(); }
static void Main(string[] args) { Director director = new Director(); Dell dell = new Dell(); director.Builder = dell; Console.WriteLine("Basic dell complectation:\n"); director.Basic(); Console.WriteLine(dell.GetComplectation().ListParts()); Console.WriteLine("Standard dell complectation:\n"); director.Standart(); Console.WriteLine(dell.GetComplectation().ListParts()); Console.WriteLine("Standard plus dell complectation:\n"); director.Standart(); Console.WriteLine(dell.GetComplectation().ListParts()); Console.WriteLine("Lux dell complectation:\n"); director.Lux(); Console.WriteLine(dell.GetComplectation().ListParts()); Console.WriteLine("-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-\n"); Sony sony = new Sony(); director.Builder = sony; Console.WriteLine("Basic sony complectation:\n"); director.Basic(); Console.WriteLine(sony.GetComplectation().ListParts()); Console.WriteLine("Standard sony complectation:\n"); director.Standart(); Console.WriteLine(sony.GetComplectation().ListParts()); Console.WriteLine("Standard plus sony complectation:\n"); director.Standart(); Console.WriteLine(sony.GetComplectation().ListParts()); Console.WriteLine("Lux sony complectation:\n"); director.Lux(); Console.WriteLine(sony.GetComplectation().ListParts()); Console.ReadLine(); }
public static void Menu1() { Dell dell = new Dell(500); Asus asus = new Asus(700); char done = 'n'; Console.WriteLine("Please choose a single or multple item"); do { Console.WriteLine("a. Dell: 500$ "); Console.WriteLine("b. Asus: 700$"); char order = char.Parse(Console.ReadLine()); switch (order) { case 'a': Count += dell.Price(); using (StreamWriter w = File.AppendText("bill.txt")) { w.WriteLine("Dell: 500$"); } break; case 'b': Count += asus.Price(); using (StreamWriter w = File.AppendText("bill.txt")) { w.WriteLine("Asus: 700$"); } break; default: Console.WriteLine("Not on the menu!"); break; } Console.Write("Order Complete?(y/n)"); done = Char.Parse(Console.ReadLine()); Console.Clear(); cashRegister += Count; }while (done == 'n' || done == 'N'); Console.WriteLine("Please take your bill"); using (StreamWriter w = File.AppendText("bill.txt")) { w.WriteLine("Total Bill: {0}", Count); } }
static void Main(string[] args) { IComputer lenovocomputer = new Lenovo(); ComputerClient lenovocliente = new ComputerClient(lenovocomputer); Console.WriteLine("********* Lenovo **********"); Console.WriteLine(lenovocliente.GetSmartPhoneModelDetails()); Console.WriteLine(lenovocliente.GetNormalPhoneModelDetails()); IComputer dellcomputer = new Dell(); ComputerClient dellcliente = new ComputerClient(dellcomputer); Console.WriteLine("******* Dell **********"); Console.WriteLine(dellcliente.GetSmartPhoneModelDetails()); Console.WriteLine(dellcliente.GetNormalPhoneModelDetails()); Console.ReadKey(); }
public static NoteBook GetNoteBook(string brand) { NoteBook nb = null; switch (brand) { case "Lenove": nb = new Lenovo(); break; case "Acer": nb = new Acer(); break; case "Dell": nb = new Dell(); break; } return(nb); }
/// <summary> /// 简单工厂的核心 根据用户的输入创建对象赋值给父类 /// </summary> /// <param name="brand"></param> /// <returns></returns> public static NoteBook GetNoteBook(string brand) { NoteBook nb = null; switch (brand) { case "Lenovo": nb = new Lenovo(); //创建子类的对象,赋值给父类 break; case "IBM": nb = new IBM(); break; case "Acer": nb = new Acer(); break; case "Dell": nb = new Dell(); break; } return(nb); }