Last active
February 14, 2019 00:25
-
-
Save robertmryan/dde5d1b2addf210b87132c9b9534d54e to your computer and use it in GitHub Desktop.
This file contains 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
// if Knight is just initializing the properties of its super class, you can omit | |
// the init method entirely, and it will inherit it from its superclass | |
class Knight: Unit { | |
// override init(pHealthPoints: Int, pDamage: Int, pMovement: Int) { | |
// self.healthPoints = pHealthPoints | |
// self.damage = pDamage | |
// self.movement = pMovement | |
// } | |
} | |
// If, on the otherhand, `Knight` really need to have some of its own properties, | |
// as well, then set the subclasses' properties and then call `super.init` | |
class Knight: Unit { | |
let name: String | |
init(name: String, pHealthPoints: Int, pDamage: Int, pMovement: Int) { | |
self.name = name | |
super.init(pHealthPoints: pHealthPoints, pDamage: pDamage, pMovement: pMovement) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment