Created
November 15, 2015 01:59
-
-
Save takaheraw/c207f27c7b1a5ee29573 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 Calculator { | |
private (set) var total = 0 | |
func add(amount: Int) { | |
total += amount | |
} | |
func subtract(amount: Int) { | |
total -= amount | |
} | |
func multiply(amount: Int) { | |
total = total * amount | |
} | |
func divide(amount: Int) { | |
total = total / amount | |
} | |
} | |
let calc = Calculator() | |
calc.add(10) | |
calc.multiply(4) | |
calc.subtract(2) | |
print("Total: \(calc.total)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment