Created
February 13, 2015 19:47
-
-
Save MichaelCPell/36b397f8c7c63d392c52 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 | |
| def self.description | |
| "Performs basic mathematical operations" | |
| end | |
| # def instance methods | |
| # calc = Calculator.new(7,2) | |
| # end | |
| def initialize(x, y) | |
| @x = x | |
| @y = y | |
| end | |
| def add | |
| @x + @y | |
| end | |
| def subtract | |
| @x - @y | |
| end | |
| def multiply | |
| @x * @y | |
| end | |
| def divide | |
| @x.to_f / @y | |
| end | |
| end | |
| # puts calc.description | |
| # puts calc. add | |
| # puts calc.subtract | |
| # puts calc.multiply | |
| # puts calc.divide |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment