Created
April 5, 2016 14:46
-
-
Save luki/40ee633cdd32210e9e8025d5ab969069 to your computer and use it in GitHub Desktop.
A calculator class in Swift.
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 Calculator { | |
let first: Double | |
let second: Double | |
init(first: Double, second: Double){ | |
self.first = first | |
self.second = second | |
} | |
func addition() -> Double { | |
return first + second | |
} | |
func subtraction() -> Double { | |
return first - second | |
} | |
func multiplication() -> Double { | |
return first * second | |
} | |
func divison() -> Double { | |
return first / second | |
} | |
} | |
let calc = Calculator(first: 4, second: 3) | |
calc.addition() | |
calc.subtraction() | |
calc.multiplication() | |
calc.divison() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment