Reid Thompson
9/15/2008 1:38:00 PM
On Mon, 2008-09-15 at 22:11 +0900, Dot Baiki wrote:
> Hello
>
> Please, can someone help me with this problem. I am really stuck. Can't
> find my problem. Simple code snippet is not working at all. I totally
> desperate.
>
> Look at this:
> --------------------start
> #!/usr/bin/env ruby
>
> class AreaOfCircle
>
> PI = 3.14159265
>
> def initialize(radius, area)
> @radius = radius
> @area = area
> end
>
> def calc_area(radius)
> @area = PI * @radius**2
> end
> end
>
> print 'Enter radius of circle: '
> keyboard_input = gets
> radius = keyboard_input.to_f
>
> instance = AreaOfCircle.new
> screen_output = instance.calc_area(keyboard_input)
> puts screen_output
> ----------------------------------- end
>
> I'm already pulling my hairs (not much left by now). Hopefully you can
> give me any hint!
>
> Regards,
> Baiki#!/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: '
keyboard_input = gets
radius = keyboard_input.to_f
instance = AreaOfCircle.new radius
screen_output = instance.calc_area(radius)
puts screen_output