Skip to content

Instantly share code, notes, and snippets.

@dcomartin

dcomartin/Stop.cs Secret

Created Apr 28, 2021
Embed
What would you like to do?
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