Last active
January 11, 2018 20:33
-
-
Save agoiabel/849418250ec26a3b52e012a5e2d2c6f8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Person { | |
let name: String | |
var age: Int | |
init(name: String, age: Int) { | |
self.name = name | |
self.age = age | |
} | |
func celebrateBirthday() { | |
self.age += 1 | |
print("Happy Birthday \(self.name)") | |
} | |
} | |
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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment