Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Last active January 11, 2018 20:33
Show Gist options
  • Save agoiabel/849418250ec26a3b52e012a5e2d2c6f8 to your computer and use it in GitHub Desktop.
Save agoiabel/849418250ec26a3b52e012a5e2d2c6f8 to your computer and use it in GitHub Desktop.
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