Renan M. answered 07/09/16
Tutor
5
(2)
Software Engineer Tutor
Here's to start you off...
class Rational
attr_accessor :n, :d
def initialize(n, d)
@numerator = n
@denominator = d
end
def *(right_hand_side)
end
def to_s
end
end
It is up to you to define those methods and add more methods as needed. Also don't forget about including parameters for each method when appropriate.
The method initialize is called once every time you create a new instance of the class (i.e. a new object).
Variables that start with an @ sign are instance variables and are accessible from any instance method.