Skip to content

Instantly share code, notes, and snippets.

@mistyrinth
Created November 24, 2018 14:13
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 mistyrinth/24666b3380f91e8481d5c44dbde862ad to your computer and use it in GitHub Desktop.
Save mistyrinth/24666b3380f91e8481d5c44dbde862ad to your computer and use it in GitHub Desktop.
# 親クラスとメソッドの定義
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