public static void CreateComputers() { var manufacturer = Console.ReadLine(); IComputersFactory computersFactory; if (manufacturer == "HP") { computersFactory = new HpComputersFactory(); } else if (manufacturer == "Dell") { computersFactory = new DellComputersFactory(); } else if (manufacturer == "Lenovo") { computersFactory = new LenovoComputersFactory(); } else { throw new InvalidArgumentException("Invalid manufacturer!"); } pc = computersFactory.CreatePersonalComputer(); laptop = computersFactory.CreteLaptop(); server = computersFactory.CreateServer(); }
static void Main(string[] args) { PersonalComputer pc = new PersonalComputer(); Console.WriteLine("Personal Computer:"); pc.Restart(); pc.RunSoftware("PUBG Mobile PC"); pc.ShutDown(); pc.StartOS(); Console.WriteLine(); Laptop laptop = new Laptop(pc) .AddKeyboard(new MechanicalKeyboard()) .AddMouse(new GamingMouse()) .AddSpeakers(new ElectrostaticLoudspeaker()); Console.WriteLine("Laptop:"); laptop.Restart(); laptop.RunSoftware("PUBG Mobile PC"); laptop.ShutDown(); laptop.StartOS(); laptop.UseKeyboard(); laptop.UseMouse(); laptop.UseSpeakers(); laptop.Hibernate(); laptop.Sleep(); laptop.UseInternalKeyboard(); laptop.UseInternalMouse(); laptop.UseInternalSpeakers(); }
public PersonalComputer CreatePersonalComputer() { var ram = new Ram(8); var videoCard = new ColofulVideoCard(); var pc = new PersonalComputer(new Cpu64(4, ram, videoCard), ram, new[] { new SingleHardDrive(1000) }, videoCard); return(pc); }
public PersonalComputer CreatePersonalComputer() { var ram = new Ram(4); var videoCard = new MonochromeVideoCard(); var pc = new PersonalComputer(new Cpu64(2, ram, videoCard), ram, new[] { new SingleHardDrive(2000), }, videoCard); return(pc); }
public void TestHasOne3() { // A.b = new B() will set B.a = A; var p = new Person {Name = "NewPerson"}; var pc = new PersonalComputer {Name = "NewPC"}; p.PC.Value = pc; Assert.AreEqual(pc.Owner.Value, p); }
public PersonalComputer CreatePersonalComputer() { var pc = new PersonalComputer( new Cpu64(2), new Ram(4), new[] { new SingleHardDrive(2000) }, new MonochromeVideoCard()); return pc; }
public PersonalComputer CreatePersonalComputer() { var pc = new PersonalComputer( new Cpu32(2), new Ram(2), new[] { new SingleHardDrive(500) }, new ColorfulVideoCard()); return pc; }
public PersonalComputer CreatePersonalComputer() { var pc = new PersonalComputer( new Cpu64(2), new Ram(4), new[] { new SingleHardDrive(2000) }, new MonochromeVideoCard()); return(pc); }
public PersonalComputer CreatePersonalComputer() { var pc = new PersonalComputer( new Cpu64(4), new Ram(8), new[] { new SingleHardDrive(1000) }, new ColorfulVideoCard()); return(pc); }
private static void CreateComputers() { var manufacturerName = Console.ReadLine(); var manufacturerFactory = new ManufacturerFactory(); IComputersFactory computerFactory = manufacturerFactory.GetManufacturer(manufacturerName); pc = computerFactory.CreatePersonalComputer(); laptop = computerFactory.CreateLaptop(); server = computerFactory.CreateServer(); }
public PersonalComputer CreatePersonalComputer() { var pc = new PersonalComputer( new Cpu64(4), new Ram(8), new[] { new SingleHardDriver(1000) }, new ColorVideoCard()); return pc; }
static void Main(string[] args) { var computer = new PersonalComputer(); var pcWithRAM = new RAMDecorator(computer); var pcWithSSD = new SSDDecorator(pcWithRAM); pcWithSSD.Startup(); Console.ReadKey(); }
private IComputer ManufacturePC() { Ram ram = new Ram(4); HardDrive hardDrive = new HardDrive(2000, false, 0); IEnumerable<HardDrive> hardDrives = new List<HardDrive>() { hardDrive }; IVideoCard videoCard = new MonochromeVideoCard(); ICpu cpu = new Cpu(2, CpuType.Bits64, new Motherboard(ram, videoCard)); IComputer pc = new PersonalComputer(cpu, ram, hardDrives, videoCard); return pc; }
public override IPersonalComputer MakePersonalComputer() { var ram = new Ram(2); var videoCard = new ColorVideoCard(); var hardDrive = new[] { new HardDrive(500, false, 0) }; IMotherboard motherboard = new Motherboard(ram, videoCard); Cpu cpu = new Cpu32Bit(2, motherboard, this.Random); var result = new PersonalComputer(motherboard, cpu, ram, hardDrive, videoCard); return result; }
static void Main(string[] args) { PersonalComputer pc = new PersonalComputer(); TV tv = new TV(); DVIProviderHDMIConsumerAdapter adapter = new DVIProviderHDMIConsumerAdapter(pc); tv.PlugIn(adapter); tv.Power(true); pc.Vlc(NetworkAttachedStorage.StarTrek); tv.Watch(); Console.ReadKey(); }
private static void CreateComputers() { var manufacturerFactory = new ManufacturerFactory(); var manufacturerName = Console.ReadLine(); IComputersFactory computerFactory = manufacturerFactory.GetManufacturer(manufacturerName); pc = computerFactory.CreatePersonalComputer(); laptop = computerFactory.CreateLaptop(); server = computerFactory.CreateServer(); }
public void TestHasOne3() { // A.b = new B() will set B.a = A; var p = new Person { Name = "NewPerson" }; var pc = new PersonalComputer { Name = "NewPC" }; p.PC.Value = pc; Assert.AreEqual(pc.Owner.Value, p); }
public void TestHasOne6() { // B has a foreign key A_id // B.a = A will set the value of B.A_id // B.a = A will set A.a = b ???? var p = DbEntry.GetObject <Person>(3); var pc = new PersonalComputer(); pc.Name = "NewPC"; pc.Owner.Value = p; Assert.AreEqual(pc.Owner.ForeignKey, 3); }
static void ComputersTask() { var gamingPC = new PersonalComputer(3700, 8, 16384, 2000); var vedroPC = new PersonalComputer(1900, 2, 4096, 240); var gamingLaptop = new Notebook(200, 2900, 4, 16384, 1000); var vedroLaptop = new Notebook(300, 1400, 2048, 6144, 1000); Console.WriteLine(gamingPC); Console.WriteLine(vedroPC); Console.WriteLine(gamingLaptop); Console.WriteLine(vedroLaptop); }
public override PersonalComputer MakePersonalComputer() { var ram = new RandomAcessMemory(PersonalComputerRam); var videoCard = new VideoCard(PersonalComputerMonochromeVideoCard); var motherBoard = new Motherboard(ram, videoCard); var cpu = new CentralProcessingUnit(PersonalComputerNumberOfCores, PersonalComputerBits, motherBoard); var hardDrive = new HardDriver(PersonalComputerHardDriveCapacity, false, 0); var dellPersonalComputer = new PersonalComputer( cpu, ram, new List<HardDriver> { hardDrive }, videoCard, motherBoard); return dellPersonalComputer; }
public void TestHasOne7() { // B.Save will save itself var p = new Person { Name = "NewPerson" }; var pc = new PersonalComputer(); pc.Name = "NewPC"; p.PC.Value = pc; DbEntry.Save(pc); Assert.IsTrue(0 != pc.Id); Assert.IsTrue(0 != p.Id); }
public void TestHasOne5() { // A.Delete will delete itself, and set B.A_id to null * var p = Person.FindById(2); Assert.IsNotNull(p); Assert.IsNotNull(p.PC.Value); var pcid = p.PC.Value.Id; // do delete p.Delete(); var p1 = Person.FindById(2); Assert.IsNull(p1); var pc = PersonalComputer.FindOne(CK.K["Person_Id"] == null); Assert.AreEqual(pcid, pc.Id); }
public override PersonalComputer MakePersonalComputer() { var ram = new RandomAcessMemory(PersonalComputerRam); var videoCard = new VideoCard(PersonalComputerMonochromeVideoCard); var motherBoard = new Motherboard(ram, videoCard); var cpu = new CentralProcessingUnit(PersonalComputerNumberOfCores, PersonalComputerBits, motherBoard); var hardDrive = new HardDriver(PersonalComputerHardDriveCapacity, false, 0); var dellPersonalComputer = new PersonalComputer( cpu, ram, new List <HardDriver> { hardDrive }, videoCard, motherBoard); return(dellPersonalComputer); }
private static void CreateComputers() { var manufacturerName = Console.ReadLine(); IComputerManufacturer manufacturer; try { manufacturer = ComputerManufacturerFactory.GetManufacturer(manufacturerName); pc = manufacturer.CreatePersonalComputer(); laptop = manufacturer.CreateLaptop(); server = manufacturer.CreateServer(); } catch (InvalidArgumentException e) { Console.WriteLine(e.Message); CreateComputers(); } }
public static void Main(string[] args) { PersonalComputer myPc = new PersonalComputer(); myPc.Guarantee = 2; myPc.Price = 1000; myPc.Provider = "World PC"; myPc.HardwarePc = new List <Hardware>(); // setting screen Screen myScreen = new Screen(); myScreen.Brand = "Samsung"; myPc.HardwarePc.Add(myScreen); // setting keyboard Keyboard myKeyboard = new Keyboard(); myKeyboard.Brand = "Genius"; myPc.HardwarePc.Add(myKeyboard); // setting mouse Mouse myMouse = new Mouse(); myMouse.Brand = "Genius"; myPc.HardwarePc.Add(myMouse); // setting case Case myCase = new Case(); myCase.Brand = "Ducky"; myPc.HardwarePc.Add(myCase); // setting camera Camera myCamera = new Camera(); myCamera.Color = "Silver"; myPc.HardwarePc.Add(myCamera); // setting speaker Speaker mySpeaker = new Speaker(); mySpeaker.Frequency = 100; myPc.HardwarePc.Add(mySpeaker); myPc.SoftwarePc = new List <Software>(); // setting softwareOS Software mySoftwareOS = new Software(); mySoftwareOS.Version = 2; mySoftwareOS.LastUpdate = DateTime.Now.AddYears(-10); mySoftwareOS.Name = "Windows XP"; myPc.SoftwarePc.Add(mySoftwareOS); Software mySoftwareApp = new Software(); mySoftwareApp.Version = 5; mySoftwareApp.LastUpdate = DateTime.Now.AddYears(-2); mySoftwareApp.Name = "League of Legends"; mySoftwareApp.Release = DateTime.Now.AddYears(-8); myPc.SoftwarePc.Add(mySoftwareApp); User myUser = new User(); myUser.FirstName = "Bill"; myUser.LastName = "Gates"; myUser.UserName = "******"; mySoftwareOS.Users = new List <User>(); mySoftwareOS.Users.Add(myUser); myScreen.Brand = "Samsung"; myPc.HardwarePc.Add(myScreen); }
private static void Dell() { var ram = new Rammstein(8); var videoCard = new HardDrive() { IsMonochrome = false }; pc = new PersonalComputer ( new Cpu(8 / 2, 64, ram, videoCard), ram, new[] { new HardDrive(1000, false, 0) }, videoCard ); var ram1 = new Rammstein(8 * 8); var card = new HardDrive(); server = new Server ( new Cpu(8, 64, ram1, card), ram1, new List<HardDrive> { new HardDrive(0, true, 2, new List<HardDrive> { new HardDrive(2000, false, 0), new HardDrive(2000, false, 0) }) }, card ); var ram2 = new Rammstein(8); var videoCard1 = new HardDrive() { IsMonochrome = false }; laptop = new Laptop ( new Cpu(8 / 2, 32, ram2, videoCard1), ram2, new[] { new HardDrive(1000, false, 0) }, videoCard1, new LaptopBattery() ); }
static void Main(string[] args) { ComponentFactory componentFactory = new ComponentFactory(); ProductFactory productFactory = new ProductFactory(); SoftwareTypes softwareTypes = new SoftwareTypes(); bool exit = false; while (!exit) { Console.WriteLine("Welcome to Our E-shop"); Console.WriteLine("What would you like to buy ?\n " + "press 'a' for PC tower\n" + "press 'b' for a PC screen\n" + "press 'c' for a Personal Computer\n" + "press 'd' for a Workstation\n" + "press 'e' to exit\n"); string answer = Console.ReadLine(); if (answer.Equals("a")) { PCTower pcTower = ConfigurePCTower(componentFactory, productFactory); if (!pcTower.IsValidProduct()) { CannotFinishTheOrder(); continue; } PrintReceiptInfo(pcTower); } else if (answer.Equals("b")) { PCScreen pcScreen = ConfigurePCScreen(productFactory); if (!pcScreen.IsValidProduct()) { CannotFinishTheOrder(); continue; } PrintReceiptInfo(pcScreen); } else if (answer.Equals("c")) { PersonalComputer personalComputer = ConfigurePersonalComputer(componentFactory, productFactory); if (!personalComputer.IsValidProduct()) { CannotFinishTheOrder(); continue; } PrintReceiptInfo(personalComputer); } else if (answer.Equals("d")) { PersonalComputer personalComputer = ConfigurePersonalComputer(componentFactory, productFactory); if (!personalComputer.IsValidProduct()) { CannotFinishTheOrder(); continue; } Console.WriteLine("Please select one of the available softwares\n"); foreach (var type in softwareTypes.Types) { Console.WriteLine(type.Value + "\n"); } answer = Console.ReadLine(); Software software = componentFactory.CreateComponent("Software") as Software; if (!software.SetValue(answer)) { WrongInput(); continue; } Workstation workstation = productFactory.CreateProduct("Workstation") as Workstation; if (!workstation.SetPersonalComputer(personalComputer) || !workstation.SetSoftware(software)) { continue; } if (!workstation.IsValidProduct()) { CannotFinishTheOrder(); continue; } PrintReceiptInfo(workstation); } else if (answer.Equals("e")) { exit = true; } else { WrongInput(); } } }
public void TestHasOne6() { // B has a foreign key A_id // B.a = A will set the value of B.A_id // B.a = A will set A.a = b ???? var p = DbEntry.GetObject<Person>(3); var pc = new PersonalComputer(); pc.Name = "NewPC"; pc.Owner.Value = p; Assert.AreEqual(pc.Owner.ForeignKey, 3); }
private static void Hp() { var ram = new Rammstein(8 / 4); var videoCard = new HardDrive() { IsMonochrome = false }; pc = new PersonalComputer ( new Cpu(8 / 4, 32, ram, videoCard), ram, new[] { new HardDrive(500, false, 0) }, videoCard ); var serverRam = new Rammstein(8 * 4); var serverVideo = new HardDrive(); server = new Server( new Cpu(8 / 2, 32, serverRam, serverVideo), serverRam, new List<HardDrive> { new HardDrive(0, true, 2, new List<HardDrive> { new HardDrive(1000, false, 0), new HardDrive(1000, false, 0) }) }, serverVideo); var card = new HardDrive() { IsMonochrome = false }; var ram1 = new Rammstein(8 / 2); laptop = new Laptop ( new Cpu(8 / 4, 64, ram1, card), ram1, new[] { new HardDrive(500, false, 0) }, card, new LaptopBattery() ); }
public void DoWork(PersonalComputer pc) { pc.StartPc(); pc.Calculate(); pc.ShutdownPc(); }
public void TestHasOne7() { // B.Save will save itself var p = new Person {Name = "NewPerson"}; var pc = new PersonalComputer(); pc.Name = "NewPC"; p.PC.Value = pc; DbEntry.Save(pc); Assert.IsTrue(0 != pc.Id); Assert.IsTrue(0 != p.Id); }