daily pastebin goal
15%
SHARE
TWEET

Untitled

a guest Feb 15th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top