Skip to content

Instantly share code, notes, and snippets.

@mikedao
Created December 25, 2014 05:24
Show Gist options
  • Save mikedao/f63ab12e3d1ba318121c to your computer and use it in GitHub Desktop.
Save mikedao/f63ab12e3d1ba318121c to your computer and use it in GitHub Desktop.
class Centaur
attr_reader :name,
:breed
def initialize(name, breed)
@name = name
@breed = breed
@actions = 0
@standing = true
end
def shoot
if cranky? || laying?
"NO!"
else
@actions += 1
"Twang!!!"
end
end
def run
if cranky? || laying?
"NO!"
else
@actions += 1
"Clop clop clop clop!!!"
end
end
def cranky?
@actions > 2 ? true : false
end
def standing?
@standing
end
def sleep
standing? ? "NO!" : @actions = 0
end
def lay_down
@standing = false
end
def laying?
!standing?
end
def stand_up
@standing = true
end
end
class Medusa
attr_reader :name,
:statues
def initialize(name)
@name = name
@statues = []
end
def stare(victim)
@statues << victim
victim.stone
end
end
class Person
attr_reader :name
def initialize(name)
@name = name
@stoned = false
end
def stone
@stoned = true
end
def stoned?
@stoned
end
end
class Werewolf
attr_reader :name,
:location,
:human
def initialize(name, location="London")
@name = name
@location = location
@human = true
end
def human?
@human
end
def change!
@human = !@human
end
def werewolf?
!human
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment