public StretchPassing(StationCall from, StationCall to) { if (from == null) throw new ArgumentNullException(nameof(from)); if (to == null) throw new ArgumentNullException(nameof(to)); if (!from.Train.Equals(to.Train)) throw new TimetableException("TODO: message"); From = from; To = to; }
internal bool IsTimeslotFree(StationCall call) { if (!_calls.Any()) return true; if (_calls.Any(c => (call.Departure >= c.Arrival && call.Departure <=c.Departure) || (call.Arrival >= c.Arrival && call.Arrival <= c.Departure))) return false; return true; }
public void Add(StationCall call) { if (call == null) throw new ArgumentNullException(nameof(call)); EnsureAscendingTimes(call); if (_calls.Any()) { call.Previous = _calls.Last(); _calls.Last().Next = call; } call.Train = this; _calls.Add(call); }
internal void Add(StationCall call) { _calls.Add(call); //if (IsTimeslotFree(call)) // throw new TimetableException(string.Format(CultureInfo.CurrentCulture, "Timeslot confict at {0} for train {1}.", call, call.Train)); }
private void EnsureAscendingTimes(StationCall call) { if (!_calls.Any()) return; if (call.Arrival <= _calls.Last().Departure) throw new TimetableException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.CallMustBeAfterPreviousCall, call, _calls.Last())); }