a
Ruby
code posted
created at 02 Jun 14:18
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
class Bicycle attr_reader :size, :chain, :tire_size def initialize(**opts) @size = opts[:size] @chain = opts[:chain] || default_chain @tire_size = opts[:tire_size] || default_tire_size end def default_chain "11-speed" end # ... end class RoadBike < Bicycle # ... def default_tire_size "23" end end class MountainBike < Bicycle # ... def default_tire_size "2.1" end end |
447 Bytes in 4 ms with coderay