Protocols in Swift - Part 4
Cracking on with protocols. Some of this will be to do with 'encapsulation' I think. Anyway, let's see what we have...! Protocol Orientated Programming Pasan goes over the example from the object-oriented Swift course, where we had different structures and classes. enum Direction { case up, down, left, right } protocol Movable { func move (_directionL Direction, by distnace: Int ) } protocol Destructable { func descreaseLife(by factor: Int ) } protocol Attackable { var strength: Int { get } var range: Int { get } func attack(player: Player ) } So all of these protocols are involved in the game I programmed before - as part of the struct/class course. The 'get' bit I'm still not too sure about. ...