Guest User

Untitled

a guest
Feb 15th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. // if Knight is just initializing the properties of its super class, you can omit
  2. // the init method entirely, and it will inherit it from its superclass
  3.  
  4. class Knight: Unit {
  5.  
  6. // override init(pHealthPoints: Int, pDamage: Int, pMovement: Int) {
  7. // self.healthPoints = pHealthPoints
  8. // self.damage = pDamage
  9. // self.movement = pMovement
  10. // }
  11.  
  12. }
  13.  
  14. // If, on the otherhand, `Knight` really need to have some of its own properties,
  15. // as well, then set the subclasses' properties and then call `super.init`
  16.  
  17. class Knight: Unit {
  18. let name: String
  19.  
  20. init(name: String, pHealthPoints: Int, pDamage: Int, pMovement: Int) {
  21. self.name = name
  22. super.init(pHealthPoints: pHealthPoints, pDamage: pDamage, pMovement: pMovement)
  23. }
  24.  
  25. }
Add Comment
Please, Sign In to add comment