-
-
Save rking/d80ef29c4dd93b8093ec 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
#!/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