Skip to content

Instantly share code, notes, and snippets.

@eduardo22i
Created April 15, 2018 21:48
Show Gist options
  • Save eduardo22i/ec0375b9bd62fae217ba2ba9a652b6ee to your computer and use it in GitHub Desktop.
Save eduardo22i/ec0375b9bd62fae217ba2ba9a652b6ee to your computer and use it in GitHub Desktop.
protocol Vehicle {
var currentSpeed : Double { get }
func accelerate()
func decelerate()
}
extension Vehicle {
var isMoving : Bool { get { return currentSpeed != 0 } }
}
protocol GroundVehicle: Vehicle {
var numberOfWheels : Int { get }
}
protocol AirVehicle: Vehicle {
func takeOff()
func land()
}
protocol WaterVehicle: Vehicle {
func submerge()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment