Created
January 8, 2013 17:15
-
-
Save rewinfrey/4485739 to your computer and use it in GitHub Desktop.
SOLID example for Alfonso
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
| # don't really need Shape class | |
| class Shape | |
| def initialize(options) | |
| end | |
| def area | |
| end | |
| end | |
| class CircleShape | |
| attr_accessor :radius | |
| def initialize(options) | |
| self.radius = options.fetch(:radius) | |
| end | |
| def area | |
| 2 * Math.pi * self.radius | |
| end | |
| end | |
| class RectangleShape | |
| attr_accessor :length, :width | |
| def initialize(options) | |
| self.length = options.fetch(:length) | |
| self.width = options.fetch(:width) | |
| end | |
| def area | |
| @length * @width | |
| end | |
| end | |
| class TriangleShape | |
| end | |
| class PolygonShape | |
| end | |
| class ProgramEmotionInterface | |
| attr_accessor :program, :emotion | |
| def initialize(options) | |
| self.program = options.fetch(:program) | |
| self.shape = options.fetch(:emotion) | |
| end | |
| def some_method_justifying_the_interface | |
| end | |
| end | |
| class ProgramShapeInterface | |
| attr_accessor :program, :shape | |
| def initialize(options) | |
| self.program = options.fetch(:program) | |
| self.shape = options.fetch(:shape) | |
| end | |
| def some_method_justifying_the_interface | |
| end | |
| end | |
| class Program | |
| attr_accessor :area_sum | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment