require_relative "purse.rb" # Purseクラスの定義を読み込む class PurseWithCard < Purse # Purseを親として引き継いでクラス定義 def initialize(money=0, card=[]) # コンストラクタ(.newで呼ばれる) super(money) # 親(Purse)の同じ名前のメソッド(initialize)を呼ぶ @card = card # 独自のインスタンス変数を導入 end def putinCard(card) @card << card printf("%s をしまいました。\n", card) end def drawCard(card) @card.delete(card) printf("%s を取り出しました。\n", card) end def myCards() @card.join(",") end end