Created
January 11, 2018 22:44
-
-
Save agoiabel/c4114dfdc7b35584f0d8dc344b15fd53 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
class Youtuber: Person { | |
let channelName: String | |
var subscribers: Int | |
//we need to pass in the name & age of the Youtuber Person | |
init(channelName: String, subscribers: Int, name: String, age: Int) { | |
self.channelName = channelName | |
self.subscribers = subscribers | |
//we use this to initialise the Person from within the subclass | |
super.init(name: String, age: Int) | |
} | |
/** This will override the celebrateBirthday in the superclass */ | |
override func celebrateBirthday() { | |
self.age += 1 | |
print("Hi, happy birthday from ur youtube subscribers") | |
} | |
} | |
Agoi: Person = Person(name: "Adeyemi", age: 27) | |
Agoi.celebrateBirthday() //Happy birthday Adeyemi | |
Abel: Youtuber = Youtuber(channelName:"Swift",subscribers:32,name:"Abel",age:27) | |
Abel.celebrateBirthday() //Hi, happy birthday from ur youtube subscribers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment