Skip to content

Instantly share code, notes, and snippets.

@ahmetkucukoglu
Last active November 3, 2023 20:44
Show Gist options
  • Save ahmetkucukoglu/ca4828b0767f08a4dcb548b2f8100b17 to your computer and use it in GitHub Desktop.
Save ahmetkucukoglu/ca4828b0767f08a4dcb548b2f8100b17 to your computer and use it in GitHub Desktop.
ConcreteState - OutForDeliveryState
public class OutForDeliveryState : ShipmentState
{
public override void Delivered(Shipment shipment)
{
Console.WriteLine("The cargo has been delivered.");
shipment.MoveTo(new DeliveredState());
}
public override void NotDelivered(Shipment shipment)
{
if (shipment.DeliveryAttempts < 1)
{
shipment.DeliveryAttempts++;
Console.WriteLine("The cargo could not be delivered. We will attempt delivery again.");
return;
}
Console.WriteLine("The cargo could not be delivered. The return process has been initiated.");
shipment.MoveTo(new NotDeliveredState());
}
public override string ToString() => nameof(OutForDeliveryState);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment