#! ruby -Ks #↑日本語を使うために class Human def initialize @weapon = nil end def swing p "『#{@weapon.name}』" p "強さ:#{@weapon.strong}" p "長さ:#{@weapon.reach}" end def set_weapon weapon @weapon = weapon end end class NormalWeapon def initialize(p_name,p_strong,p_reach) @name = p_name @strong = p_strong @reach = p_reach end def name @name end def strong @strong end def reach @reach end end class AbnomarlWeapon < NormalWeapon def initialize(p_name,p_strong,p_reach) super @count = 1 end def strong @strong * @count end def reach rea = @reach * @count @count += 1 return rea end end #ここなんかはリストにするのか、 hand = NormalWeapon.new("素手",1,1) rod = NormalWeapon.new("こんぼう",3,5) three_rod = AbnomarlWeapon.new("三節棍",1,1) human = Human.new human.set_weapon(hand) human.swing human = Human.new human.set_weapon(rod) human.swing human = Human.new human.set_weapon(three_rod) human.swing human.swing