From: Lloyd Linklater Date: 2008-09-15T23:18:27+09:00 Subject: Re: Need someone who can help Dot Baiki wrote: > Hey! Amazing quick response! Outstanding. Sweet solutions! Will continue > reading my books I bought. Really cool. Thanks so much. This is what I > made now: > > --- begin --- > #!/usr/bin/env ruby > > class AreaOfCircle > > PI = 3.14159265 > > def initialize(radius) > @radius = radius > @area = nil > end > > def calc_area(radius) > @area = PI * @radius**2 > end > end > > print 'Enter radius of circle: ' > radius = gets.to_f > puts "You entered: #{radius}" > > instance = AreaOfCircle.new(radius) > screen_output = instance.calc_area(radius) > puts "Result: #{screen_output}" > --- end --- > > You know, the cool thing is that I really soooooon will understand Ruby > and its beauty :-) > > Baiki I am glad that it helped, though it seems that you have more than you strictly seem to need. e.g. class AreaOfCircle PI = 3.14159265 def calc_area(radius) PI * radius**2 end end is plenty. Note: no parameter needed for the AreaOfCircle.new -- Posted via http://www.ruby-forum.com/.