Created
May 26, 2015 15:20
-
-
Save elkraneo/15b07b70ab11b3ad248e to your computer and use it in GitHub Desktop.
Overriding Properties
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 Vehicle { | |
var currentSpeed = 0.0 | |
var description: String { | |
return "traveling at \(currentSpeed) miles per hour" | |
} | |
func makeNoise() { | |
// do nothing - an arbitrary vehicle doesn't necessarily make a noise | |
} | |
} | |
class Car: Vehicle { | |
var gear = 1 | |
override var description: String { | |
return super.description + " in gear \(gear)" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment