# prac0302.rb
# 図形クラスの面積計算

class Triangle
  def initialize(teihen,takasa)
    @teihen = teihen
    @takasa = takasa
  end
  def menseki
    return @teihen * @takasa / 2.0
  end
end

class Rectangle
  def initialize(teihen,takasa)
    @teihen = teihen
    @takasa = takasa
  end
  def menseki
    return @teihen * @takasa
  end
end

class Circle
  def initialize(hankei)
    @hankei = hankei
  end
  def menseki
    return Math::PI * @hankei ** 2
  end
end

objs = Array.new
objs << Triangle.new(3,4)
objs << Rectangle.new(2,5)
objs << Triangle.new(4,4)
objs << Circle.new(2)
objs << Triangle.new(6,4)

objs.each{ |obj|
  print obj.menseki,"\n"
}