public CheckSystemBlockCommand(SystemBlock systemBlock, SystemBlockComponents components, ISystemBlockHandler handler, INavigationService navigation) { this.handler = handler; this.systemBlock = systemBlock; this.components = components; this.navigation = navigation; }
public bool Validate(ISystemBlockHandler systemBlock) { foreach (ComponentType componentType in Enum.GetValues(typeof(ComponentType))) { if (!systemBlock.GetContainer(componentType).IsValid()) { return(false); } } return(Next == null ? true : Next.Validate(systemBlock)); }
public bool Validate(ISystemBlockHandler systemBlock) { var systemBlockHull = (SystemBlockHull)systemBlock.GetContainer(ComponentType.SystemBlockHull).GetItems().FirstOrDefault(); var powerSupply = (PowerSupply)systemBlock.GetContainer(ComponentType.PowerSupply).GetItems().FirstOrDefault(); if (!systemBlockHull.CanAccommodatePowerSupply(powerSupply)) { return(false); } return(Next == null ? true : Next.Validate(systemBlock)); }
public bool Validate(ISystemBlockHandler systemBlock) { var powerSupply = (PowerSupply)systemBlock.GetContainer(ComponentType.PowerSupply).GetItems().FirstOrDefault(); var consumers = systemBlock.GetPowerConsumers(); if (!powerSupply.HasEnoughPower(consumers)) { return(false); } return(Next == null ? true : Next.Validate(systemBlock)); }
public void ProcessSystemBlock() { ISystemBlockHandler handler = CollectSystemBlock(); if (handler.IsWorking()) { Console.WriteLine($"System block is working. The price is ${handler.Price}"); } else { Console.WriteLine("System block can not be collected"); } }