Last active
August 29, 2015 14:04
-
-
Save kaiwren/c7b4a17aa73b0be45b22 to your computer and use it in GitHub Desktop.
RubyMonk Example with output
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 Rectangle | |
def initialize(length, breadth) | |
@length = length | |
@breadth = breadth | |
end | |
def perimeter | |
2 * (@length + @breadth) | |
end | |
def area | |
@length * @breadth | |
end | |
end | |
rectangle = Rectangle.new(5, 2) | |
puts rectangle.perimeter | |
puts rectangle.area |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's brilliant 14 and 10 are returned on the command line. Thanks Sidu.