Sha256: 85652e2b047318e7cc1ae25f2d476947feaaa45439227ef369fef6676b1a62f4
Contents?: true
Size: 642 Bytes
Versions: 1
Compression:
Stored size: 642 Bytes
Contents
require_relative 'player' module StudioGame class ClumsyPlayer < Player def found_treasure(treasure) damaged_treasure = Treasure.new(treasure.name, treasure.points / 2.0) super(damaged_treasure) end end end if __FILE__ == $0 clumsy = ClumsyPlayer.new("klutz") hammer = Treasure.new(:hammer, 50) clumsy.found_treasure(hammer) clumsy.found_treasure(hammer) clumsy.found_treasure(hammer) crowbar = Treasure.new(:crowbar, 400) clumsy.found_treasure(crowbar) clumsy.each_found_treasure do |treasure| puts "#{treasure.points} total #{treasure.name} points" end puts "#{clumsy.points} grand total points" end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
studio_game_20150214-1.0.0 | lib/studio_game/clumsy_player.rb |