Created
          October 11, 2012 02:54 
        
      - 
      
- 
        Save ajmalafif/3869895 to your computer and use it in GitHub Desktop. 
    Bloc Shape Challenge
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class Shape | |
| attr_reader :color | |
| def initialize(color) | |
| @color = color | |
| end | |
| def can_fit?(shape) | |
| self.area < shape.area ? true : false | |
| end | |
| def can_fit(shape) | |
| self.area / shape.area | |
| end | |
| end | |
| class Rectangle < Shape | |
| def initialize(width, height, color = "Red") | |
| super(color) | |
| @width = width | |
| @height = height | |
| end | |
| def area | |
| @width * @height | |
| end | |
| end | |
| class Square < Shape | |
| def initialize(side, color = "Red") | |
| super(color) | |
| @side = side | |
| end | |
| def area | |
| @side * @side | |
| end | |
| end | |
| class Circle < Shape | |
| def initialize(radius, color = "Red") | |
| super(color) | |
| @radius = radius | |
| end | |
| def area | |
| @radius ** 2 * Math::PI | |
| end | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment