Created
July 21, 2018 21:39
-
-
Save jaymcgavren/3fdaf65cbbab16ac5be3df7852f43adc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.