Sha256: 6f26833fdd0b8ebeb66fe04b515437b8f089f55e06e06780dcace7894fc3cbb0

Contents?: true

Size: 502 Bytes

Versions: 2

Compression:

Stored size: 502 Bytes

Contents

module TwentyOne
	class Chip
		attr_reader :color, :value

		def initialize(color)
			@color = color

			case color
			when :white
				@value = 1
			when :red
				@value = 5
			when :green
				@value = 25 
			when :black
				@value = 100
			end
		end

		def self.generate_chips(color, total)
			set  = []

			total.times do
				set.push Chip.new(color)	
			end

			set
		end

		def self.get_amount(chips)
			amount = 0

			chips.each do |chip|
				amount += chip.value
			end

			amount
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twenty_one-0.1.1 lib/twenty_one/chip.rb
twenty_one-0.1.0 lib/twenty_one/chip.rb