classDiedefroll
rand(6)+1endendclassDicedefinitialize@die1=Die.new@die2=Die.newenddefroll@die1.roll +@die2.roll
end#I don't like the nils here but this works for now.
#if anyone can clean this up, go for it :)
defbuild_histogram(number)@histogram=[nil,nil,0,0,0,0,0,0,0,0,0,0,0]
number.times {@histogram[roll]+=1}enddefprint_histogramif@histogramfor index in2..12
print "#{index}\t| "
print "*"*@histogram[index]
print "\n"endelse
puts "No histogram to print"endendend
d =Dice.new
d.build_histogram(100)
d.print_histogram
puts
d.build_histogram(400)
d.print_histogram