This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class Stop | |
{ | |
public int StopId { get; set; } | |
public StopStatus Status { get; set; } | |
public int Sequence { get; set; } | |
public void Arrive() | |
{ | |
if (Status != StopStatus.InTransit) | |
{ | |
throw new InvalidOperationException("Stop has already arrived."); | |
} | |
Status = StopStatus.Arrived; | |
} | |
public void Depart() | |
{ | |
if (Status == StopStatus.Departed) | |
{ | |
throw new InvalidOperationException("Stop has already departed."); | |
} | |
if (Status == StopStatus.InTransit) | |
{ | |
throw new InvalidOperationException("Stop hasn't arrived yet."); | |
} | |
Status = StopStatus.Departed; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment