-
-
Save mistyrinth/24666b3380f91e8481d5c44dbde862ad 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
# 親クラスとメソッドの定義 | |
class Car | |
def accele | |
print("アクセルを踏みました\n") | |
end | |
def brake | |
print("ブレーキを踏みました\n") | |
end | |
end | |
# 子クラスへの継承 | |
class Soarer < Car | |
def openRoof | |
print("ルーフを開けました\n") | |
end | |
# メソッドのオーバーライド | |
def accele | |
print("アクセルを踏んで加速しました\n") | |
end | |
end | |
car = Car.new | |
car.accele | |
soarer = Soarer.new | |
soarer.accele |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment