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 Shipment | |
{ | |
public Guid OrderId { get; private set; } | |
public string FromCountry { get; private set; } | |
public string To { get; private set; } | |
public ShipmentState State { get; private set; } | |
public int DeliveryAttempts { get; internal set; } | |
public Shipment(Guid orderId, string fromCountry, string to) | |
{ |
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 NotDeliveredState : ShipmentState | |
{ | |
public override string ToString() => nameof(NotDeliveredState); | |
} |
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 DeliveredState : ShipmentState | |
{ | |
public override string ToString() => nameof(DeliveredState); | |
} |
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) |
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 CustomsClearedState : ShipmentState | |
{ | |
public override void OutForDelivery(Shipment shipment) | |
{ | |
Console.WriteLine("The cargo is out for delivery."); | |
shipment.MoveTo(new OutForDeliveryState()); | |
} | |
public override string ToString() => nameof(CustomsClearedState); |
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 InCustomsState : ShipmentState | |
{ | |
public override void CustomsCleared(Shipment shipment) | |
{ | |
Console.WriteLine("Customs clearance procedures have been completed."); | |
shipment.MoveTo(new CustomsClearedState()); | |
} | |
public override string ToString() => nameof(InCustomsState); |
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 InTransitState : ShipmentState | |
{ | |
public override void InCustoms(Shipment shipment) | |
{ | |
Console.WriteLine("The cargo has arrived at customs."); | |
shipment.MoveTo(new InCustomsState()); | |
} | |
public override string ToString() => nameof(InTransitState); |
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; | |
} |
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 abstract class ShipmentState | |
{ | |
public virtual void InTransit(Shipment shipment) | |
{ | |
Console.WriteLine(GetInvalidMessage(nameof(InTransit), shipment.State)); | |
} | |
public virtual void InCustoms(Shipment shipment) | |
{ | |
Console.WriteLine(GetInvalidMessage(nameof(InCustoms), shipment.State)); |
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 Shipment | |
{ | |
public Guid OrderId { get; private set; } | |
public string FromCountry { get; private set; } | |
public string ToAddress { get; private set; } | |
public ShipmentStatuses Status { get; private set; } | |
public int DeliveryAttempts { get; internal set; } | |
public Shipment(Guid orderId, string fromCountry, string toAddress) | |
{ |