Skip to content

Instantly share code, notes, and snippets.

@troyleach
Created January 21, 2015 22:22
Show Gist options
  • Select an option

  • Save troyleach/dd448276ddf149724a4c to your computer and use it in GitHub Desktop.

Select an option

Save troyleach/dd448276ddf149724a4c to your computer and use it in GitHub Desktop.
screencast 17
#screen cast 17
class Calculator
include Math
def add(num1, num2)
num1 + num2
end
def multiply(num1, num2)
num1 * num2
end
def divide(num1, num2)
num1 / num2
end
def subtract(num1, num2)
num1 - num2
end
def circumference_of_a_circle(radius)
@c = 2 * PI * radius
end
def what_is_the_radus(input)
circumference_of_a_circle(input)
end
def display_answer
"The circumference of the circle is #{@c.round(3)}"
end
end
calc = Calculator.new
p calc.add(2, 4)
p calc.multiply(4, 4)
p calc.divide(10, 5)
p calc.subtract(50, 100)
print "Enter a radius: "
calc.what_is_the_radus(gets.chomp.to_i)
p calc.display_answer
@markeban

Copy link
Copy Markdown

I love the circumference method - I think you're the first to come up with that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment