Skip to content

Instantly share code, notes, and snippets.

@jaymcgavren
Created July 21, 2018 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaymcgavren/3fdaf65cbbab16ac5be3df7852f43adc to your computer and use it in GitHub Desktop.
Save jaymcgavren/3fdaf65cbbab16ac5be3df7852f43adc to your computer and use it in GitHub Desktop.
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
Copy link
Author

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