At the outset, it may not be clear as to what is the best structure to use for defining a transport method; indeed, there might be different structures appropriate for different methods. Therefore, we will define a transport method as a protocol that appropriate types can conform to:
protocol TransportMethod { associatedtype CollectionPoint var defaultCollectionPoint: CollectionPoint { get } var averageSpeedInKPH: Double { get } }
We define an associated generic type that we name CollectionPoint, which will represent the type of location that someone can be collected from when using this TransportMethod. By using generics, we have ultimate flexibility in how a transport method chooses to define what can serve as a collection ...