class Adder def add( a, b ) a.to_f + b.to_f end end class Subtractor def subtract( a, b ) a.to_f - b.to_f end end class Multiplier def multiply( a, b ) a.to_f * b.to_f end end class Divider def divide( a, b ) a.to_f / b.to_f end end class Calculator attr_writer :adder attr_writer :subtractor attr_writer :multiplier attr_writer :divider def add( a, b ) @adder.add( a, b ) end def subtract( a, b ) @subtractor.subtract( a, b ) end def multiply( a, b ) @multiplier.multiply( a, b ) end def divide( a, b ) @divider.divide( a, b ) end end