Last active
November 3, 2023 20:44
-
-
Save ahmetkucukoglu/ca4828b0767f08a4dcb548b2f8100b17 to your computer and use it in GitHub Desktop.
ConcreteState - OutForDeliveryState
This file contains hidden or 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 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