Created
June 19, 2012 15:31
-
-
Save na0w0/2954818 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Magic | |
def initialize(attack_point,defense_point) | |
@attack_point = attack_point | |
@defense_point = defense_point | |
@level = 1 | |
end | |
def level_up | |
@level += 1 | |
end | |
def attack | |
@attack_point * @level | |
end | |
def defense | |
@defense_point * @level | |
end | |
end | |
nanoha = Magic.new(10,5) | |
fate = Magic.new(8,4) | |
p nanoha.level_up | |
p nanoha.attack | |
p nanoha.defense | |
p fate.level_up | |
p fate.attack | |
p fate.defense | |
p nanoha.level_up | |
p nanoha.attack | |
p nanoha.defense | |
p fate.level_up | |
p fate.attack | |
p fate.defense |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment