Last active
November 3, 2023 20:43
-
-
Save ahmetkucukoglu/50eb3c43d5a9001772dc5bc73ee293ac to your computer and use it in GitHub Desktop.
ConcreteState - OrderPlacedState
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 OrderPlacedState : ShipmentState | |
{ | |
public override void InTransit(Shipment shipment) | |
{ | |
if (shipment.FromCountry == "TR") | |
{ | |
Console.WriteLine(GetInvalidMessage(nameof(InTransit), shipment.State)); | |
return; | |
} | |
Console.WriteLine("The cargo has been loaded onto the ship."); | |
shipment.MoveTo(new InTransitState()); | |
} | |
public override void OutForDelivery(Shipment shipment) | |
{ | |
if (shipment.FromCountry != "TR") | |
{ | |
Console.WriteLine(GetInvalidMessage(nameof(OutForDelivery), shipment.State)); | |
return; | |
} | |
Console.WriteLine("The cargo is out for delivery."); | |
shipment.MoveTo(new OutForDeliveryState()); | |
} | |
public override string ToString() => nameof(OrderPlacedState); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment