Skip to content

Instantly share code, notes, and snippets.

@wannabefro
Created February 21, 2014 21:46
Show Gist options
  • Save wannabefro/9144171 to your computer and use it in GitHub Desktop.
Save wannabefro/9144171 to your computer and use it in GitHub Desktop.
require 'pry'
VALID_INPUT = [1,2,3,4]
@products = []
def get_choice
puts 'Enter your selection'
choice = gets.chomp.to_i
validate_choice(choice)
scan(choice)
end
def validate_choice(choice)
if !VALID_INPUT.include?(choice)
puts 'I hate you'
get_choice
end
end
def scan(choice)
if finished?(choice)
puts @products
else
@products << choice
get_choice
end
end
def finished?(choice)
choice == 4
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment