class CootieCatcher
Constants
- COLORS
- FORTUNES
- NUMBERS
Attributes
color_choice[R]
next_random_number[R]
number_choice[R]
random_color[R]
random_number[R]
second_number_choice[R]
Public Instance Methods
continue()
click to toggle source
# File lib/cootie_catcher.rb, line 41 def continue if valid_number? second_number else print_bad_number_input_message play end end
play()
click to toggle source
# File lib/cootie_catcher.rb, line 29 def play color if valid_color? number continue else print_bad_color_input_message play end fortune end
Private Instance Methods
color()
click to toggle source
# File lib/cootie_catcher.rb, line 53 def color puts "\nPick a color: " @random_color = COLORS.sample(4) puts random_color @color_choice = gets.chomp.downcase end
fortune()
click to toggle source
# File lib/cootie_catcher.rb, line 90 def fortune puts "\n" puts FORTUNES.sample end
number()
click to toggle source
# File lib/cootie_catcher.rb, line 68 def number puts "\nPick a number: " @random_number = NUMBERS.sample(4) puts random_number @number_choice = gets.chomp.to_i end
print_bad_color_input_message()
click to toggle source
# File lib/cootie_catcher.rb, line 64 def print_bad_color_input_message puts "Sorry, #{color_choice} is not a valid choice. Start over.\n" end
print_bad_number_input_message()
click to toggle source
# File lib/cootie_catcher.rb, line 79 def print_bad_number_input_message puts "Sorry, #{number_choice} is not a valid choice. Start over.\n" end
second_number()
click to toggle source
# File lib/cootie_catcher.rb, line 83 def second_number puts "\nPick a number: " @next_random_number = NUMBERS.sample(4) puts next_random_number @second_number_choice = gets.chomp end
valid_color?()
click to toggle source
# File lib/cootie_catcher.rb, line 60 def valid_color? @random_color.include?(@color_choice.upcase) end
valid_number?()
click to toggle source
# File lib/cootie_catcher.rb, line 75 def valid_number? @random_number.include?(number_choice) end