Skip to content

Instantly share code, notes, and snippets.

@rking

rking/grieg.rb Secret

Created November 8, 2012 06:12
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 rking/d80ef29c4dd93b8093ec to your computer and use it in GitHub Desktop.
Save rking/d80ef29c4dd93b8093ec to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
class Char
attr_reader :str, :dex, :int
def initialize
@str = 1
@dex = 1
@int = 1
end
end
class Warrior < Char
def initialize
super
@str += 2
@dex += 1
end
end
class Thief < Char
def initialize
super
@dex += 2
@int += 1
end
end
player = Thief.new
p player.int # ⇒ 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment