private bool CanPlugIn(ElectricalLoad electricalLoad) { if (Load + electricalLoad.Power <= TotalPower) { return(true); } return(false); }
public void Add(ElectricalLoad electricalLoad) { if (electricalLoad == null) { throw new ArgumentNullException(nameof(electricalLoad)); } ElectricalLoads.Add(electricalLoad); }
public void PlugIn(int socketNumber, ElectricalLoad electricalLoad) { if (socketNumber < 0 || socketNumber > ElectricalLoads.Length - 1) { throw new ArgumentOutOfRangeException(nameof(socketNumber)); } if (electricalLoad == null) { throw new ArgumentOutOfRangeException(nameof(electricalLoad)); } if (ElectricalLoads[socketNumber] != null) { Unplug(socketNumber); } if (CanPlugIn(electricalLoad)) { ElectricalLoads[socketNumber] = electricalLoad; Load += electricalLoad.Power; } }