I am running a program where I want the use to be able to select 1-28 and the program will print_details. However if the user types in ANYTHING else I want to print an error.
def list_menu
puts "Type the episode number you want more information on.".cyan
input = gets.strip
# if input.between? (0, 27)
# #ask for user input
# #validate user input with a conditional
print_details(gets.strip)
# elsif
# puts "That's not a valid number!"
# list_menu
puts "Is there another episode you would like details on? Y/N".cyan
input = gets.strip
if input == "Y"
list_episode
list_menu
elsif input == "y"
list_episode
list_menu
elsif input == "N"
bye
elsif input == "n"
bye
else
puts "ERROR".red
list_menu
end
end
I have commented out what I was attempting. As of right now the program runs, but if I were to type "0" it would print details from the last episode
Aucun commentaire:
Enregistrer un commentaire