Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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)
- }
- }
Add Comment
Please, Sign In to add comment