-
-
Save mthouser/d96a74b927e4fbbc049c to your computer and use it in GitHub Desktop.
Swift Presentation - 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
protocol Exercising { | |
var heartRateIncrement : Int { get set } | |
func describe() -> String | |
} | |
class Sprint : Exercising { | |
var isWindSprint : Bool { | |
get { | |
return heartRateIncrement > 40 | |
} | |
} | |
init() { | |
heartRateIncrement = 30 | |
} | |
var heartRateIncrement : Int { | |
willSet (newIncrementor) { | |
println("About to set incrementor to \(newIncrementor)") | |
} | |
didSet { | |
println("Set incrementor to \(heartRateIncrement)") | |
} | |
} | |
func describe() -> String { | |
if isWindSprint { | |
return "Windsprinting" | |
} else { | |
return "Sprinting" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment