Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created April 28, 2021 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcomartin/6244d41a7d5d24498e3b81b71f85a4d8 to your computer and use it in GitHub Desktop.
Save dcomartin/6244d41a7d5d24498e3b81b71f85a4d8 to your computer and use it in GitHub Desktop.
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