class Code
	def initialize
		generate
	end

	def match_with_string(code)
		secret_code_clone = @secret_code.clone
		code.chars.each do |c|
			secret_code_clone.sub!(c, "")
		end

		strong_match = 0

		4.times do |i|
			strong_match += 1 if @secret_code[i] == code[i]
		end

		matched_only_value = 4 - secret_code_clone.length - strong_match

		result = ""
		strong_match.times {result << "+"}
		matched_only_value.times {result << "-"}

		result
	end

	def random_number
		@secret_code[rand(4)]
	end

	private
	def generate
		@secret_code = (rand * 0.6 * 10000).round.to_s
	end
end
