Created
June 2, 2013 10:59
-
-
Save uiur/5693303 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
# encoding: UTF-8 | |
class Pikachu | |
# インスタンス変数へのアクセサ | |
attr_accessor :hp, :attack, :defence | |
def initialize(hp, attack, defence) | |
# インスタンス変数に代入する | |
@hp = hp | |
@attack = attack | |
@defence = defence | |
end | |
# インスタンスメソッド | |
def denkishock | |
# なんかやる | |
end | |
# インスタンスメソッド | |
def denziha | |
# なんかやる | |
end | |
end | |
p = Pikachu.new(100, 10, 10) | |
puts p.hp | |
puts p.attack | |
p.denkishock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment