如何让用户输入圆的半径?
class Circle
@@PI = 3.14
def initialize
@radius = 0
end
def set_radius radius
@radius = radius
end
def area
@radius * @radius * @@PI
end
end
c = Circle.new
c.set_radius 5
puts c.area
我知道我将使用以下内容:gets.chomp
.