probability/test.rb
#simplify this entire section
#captures user input regarding release run
simplify this entire section
captures user input regarding release run
simplify this entire section captures user input regarding release run
def user_input
puts "Please enter quantity of each color:"
puts "Grey"
@user_grey = gets.to_i
puts "Yellow"
@user_yellow = gets.to_i
puts "Blue"
@user_blue = gets.to_i
puts "Red"
@user_red = gets.to_i
puts "Green"
@user_green = gets.to_i
@user_total = [@user_grey + @user_yellow + @user_blue + @user_red + @user_green]
@user_int = @user_total.inject(0){|sum,x| sum + x }
if @user_int != 5
  then puts "\nERROR: The inputted quantity must be exactly five. Correct your input and try again. \n ".red 
  user_input
end
if (@var = @user_grey.to_s.include? "0") and @var == true
  then
  @user_grey = 1
end
if (@var = @user_yellow.to_s.include? "0") and @var == true
  then
  @user_yellow = 1
end
if (@var = @user_blue.to_s.include? "0") and @var == true
  then
  @user_blue = 1
end
if (@var = @user_red.to_s.include? "0") and @var == true
  then
  @user_red = 1
end
if (@var = @user_green.to_s.include? "0") and @var == true
  then
  @user_green = 1
end
overall
  end
def user_input puts "Please enter quantity of each color:" puts "Grey" @user_grey = gets . to_i puts "Yellow" @user_yellow = gets . to_i puts "Blue" @user_blue = gets . to_i puts "Red" @user_red = gets . to_i puts "Green" @user_green = gets . to_i @user_total = [ @user_grey + @user_yellow + @user_blue + @user_red + @user_green ] @user_int = @user_total . inject ( 0 ) { | sum , x | sum + x } if @user_int != 5 then puts "\nERROR: The inputted quantity must be exactly five. Correct your input and try again. \n " . red user_input end if ( @var = @user_grey . to_s . include? "0" ) and @var == true then @user_grey = 1 end if ( @var = @user_yellow . to_s . include? "0" ) and @var == true then @user_yellow = 1 end if ( @var = @user_blue . to_s . include? "0" ) and @var == true then @user_blue = 1 end if ( @var = @user_red . to_s . include? "0" ) and @var == true then @user_red = 1 end if ( @var = @user_green . to_s . include? "0" ) and @var == true then @user_green = 1 end overall end
simplify this entire section
captures user input regarding release run
simplify this entire section captures user input regarding release run
#requests user_input regarding the color traits of the release run #using inject() to get array total #checks to see if the overall user_input quantity totals five; throws error if it is not. #uses Colorize gem #checking to see if the user_input quantity is zero; if so, it replaces it with a value of 1