I'm supposed to include it in the Shape class but how do I compare if one shape fits inside another in the Shape class if we're using area to compare, and Shape doesn't have access to area? class ShapeĪttr_accessor :color, :shape, :width, :heightĭef initialize(width, height, = height So I've created the shape class just fine and am calculating the areas of square, rectangle and circle just fine.īut I'm completely stumped on the can_fit? method. The classes should also be able to call a can_fit? method which evalulates two shapes and returns true or false based on one shape fitting inside the other. (There's also a part about being able to set a color as well as inherit the default color, but that's not the part I'm stumped on, so I won't include the specs here.) You should be able to calculate the area of each shape. I'm presented with this code challenge:Ĭreate classes to represent a square, rectangle and circle.
0 Comments
Leave a Reply. |