Instantly share code, notes, and snippets.

Embed
What would you like to do?
class Mousetrap
attr_accessor :marble_count
def initialize(marble_count)
self.marble_count = marble_count
end
def press_button
print "presses the button which "
flip_bucket
end
def flip_bucket
print "flips the bucket which "
drop_marble
end
def drop_marble
if marble_count <= 0
print "does nothing."
return
end
print "drops a marble which "
self.marble_count -= 1
press_button
end
end
print "My finger "
Mousetrap.new(5).press_button
@jaymcgavren

This comment has been minimized.

Owner

jaymcgavren commented Jul 21, 2018

My finger presses the button which flips the bucket which drops a marble which presses the button which flips the bucket which drops a marble which presses the button which flips the bucket which drops a marble which presses the button which flips the bucket which drops a marble which presses the button which flips the bucket which drops a marble which presses the button which flips the bucket which does nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment