class Treehouse def initialize(ladder, happyduckslide, sadsharkslide) @ladder = ladder # => # @happyduckslide = happyduckslide # => #> @sadsharkslide = sadsharkslide # => #> end # => :initialize def ride name = @ladder.gets().chomp() # => "Josh", "Anna Marie" if rand(2) == 1 # => true, false @happyduckslide.puts("#{name} climbs the ladder, slides into the lake, and swims with the ducks!") # => nil else @sadsharkslide.puts("#{name} climbs the ladder, slides into the ocean, and gets devoured by the shark!") # => nil end # => nil, nil end # => :ride end require 'stringio' # => true ladder = StringIO.new "Josh\nAnna Marie" # => # happyduckslide = $stdout # => #> sadsharkslide = $stderr # => #> treehouse = Treehouse.new(ladder, happyduckslide, sadsharkslide) # => #, @happyduckslide=#>, @sadsharkslide=#>> treehouse.ride # => nil treehouse.ride # => nil # There's a super cool new treehouse down the block. # It has a ladder that takes a person into the house and two slides that drops them out into a lake. # Anyone can go for a slide ride. # # >> Josh climbs the ladder and slides into the lake! # !> Anna Marie climbs the ladder and slides into the lake!