--- Revision None +++ Revision 353536656433 @@ -0,0 +1,16 @@ +class << LotteryDraw + def play + final = LotteryTicket.new_random + winners = {} + @@tickets.each do |buyer, ticket_list| + ticket_list.each do |ticket| + score = ticket.score( final ) + next if score.zero? + winners[buyer] ||= [] + winners[buyer] << [ ticket, score ] + end + end + @@tickets.clear + winners + end + end