private void RegisterComponent(string component) { int startIndexOfComponentArguments = component.IndexOf('('); string typeComponent = component.Substring(0, startIndexOfComponentArguments); string[] componentArguments = SplitByMultipleChars( component.Substring(startIndexOfComponentArguments)); if (typeComponent.Contains("Hardware")) { IComponentHardware newHardware = hardwareFactory.CreateHardware( typeComponent, componentArguments[0], int.Parse(componentArguments[1]), int.Parse(componentArguments[2])); this.newMachine.AddHardwareItem(newHardware); } else { IComponentSoftware newSoftware = softwareFactory.CreateSoftware(typeComponent, componentArguments[1], int.Parse(componentArguments[2]), int.Parse(componentArguments[3])); this.newMachine.AddSoftwareItem(componentArguments[0], newSoftware); } }
private int GetCountOfSpecificSoftwareComponets(IComponentHardware hardware, string nameOfSoftware) { int countSoftware = hardware.SoftwareComponets .Where(x => x.GetType().Name.Contains(nameOfSoftware)) .Count(); return(countSoftware); }
public IComponentHardware CreateHardware(string type, string name, int capacity, int memory) { IComponentHardware componentHardware = null; switch (type) { case "PowerHardware": return(componentHardware = new PowerHardware(name, capacity, memory, type)); break; case "HeavyHardware": return(componentHardware = new HeavyHardware(name, capacity, memory, type)); break; } return(componentHardware); }
public void AddHardwareItem(IComponentHardware item) { this.hardwareComponents.Add(item); }
public int GetCapacityUsed(IComponentHardware currentHardware) { int capacity = currentHardware.SoftwareComponets.Sum(x => x.CapacityConsumption); return(capacity); }
public int GetMemoryUsed(IComponentHardware currentHardware) { int memory = currentHardware.SoftwareComponets.Sum(x => x.MemoryConsumption); return(memory); }