Guest User

Untitled

a guest
Jan 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. class Youtuber: Person {
  2.  
  3. let channelName: String
  4. var subscribers: Int
  5.  
  6. //we need to pass in the name & age of the Youtuber Person
  7. init(channelName: String, subscribers: Int, name: String, age: Int) {
  8. self.channelName = channelName
  9. self.subscribers = subscribers
  10.  
  11. //we use this to initialise the Person from within the subclass
  12. super.init(name: String, age: Int)
  13. }
  14.  
  15. /** This will override the celebrateBirthday in the superclass */
  16. override func celebrateBirthday() {
  17. self.age += 1
  18. print("Hi, happy birthday from ur youtube subscribers")
  19. }
  20.  
  21. }
  22.  
  23. Agoi: Person = Person(name: "Adeyemi", age: 27)
  24. Agoi.celebrateBirthday() //Happy birthday Adeyemi
  25.  
  26.  
  27. Abel: Youtuber = Youtuber(channelName:"Swift",subscribers:32,name:"Abel",age:27)
  28. Abel.celebrateBirthday() //Hi, happy birthday from ur youtube subscribers
Add Comment
Please, Sign In to add comment