begin29
2/7/2017 - 7:54 PM

figure task from Denys

figure task from Denys

class Figure

  attr_reader :radius

  def initialize(color,radius)
    @color = color
    @radius = radius
    raise "first argument needs to be a string" unless color.class  == String
    raise "second argument needs to be a fixnum" unless radius.class  == Fixnum
  end

  def calculate_area
    puts "#{@color.to_s} #{self.class.to_s.downcase} has #{self.prepared_area.round(2).to_s} area}"
  end
end

class Circle < Figure

  def prepared_area
    p radius**2 * Math::PI
  end


end

class Square < Figure

  def prepared_area
    p radius**2
  end

end


c = Circle.new('blue', 10)
c.calculate_area

sq = Square.new('yellow', 12)
sq.calculate_area