Code became unresponsive 8.display


#1




Whenever I put anything into the input, it just executes the 'add' line of code. When I put in 'display' it just does add. Not sure what got broken along the way, it was working before.


movies = {genericMovie: 3}
puts "Please input"
choice = gets.chomp.downcase


case 
when 'add'
    puts "Movie title?"
    title = gets.chomp
    if movies[title.to_sym].nil?
        puts "What's the rating? (Type a number 0 to 4.)"
        rating = gets.chomp
        movies[title.to_sym] = rating.to_i
        puts "#{title} has been added with a rating of #{rating}."
    else
      puts "That movie already exists! Its rating is #{movies[title.to_sym]}."
    end
when 'update'
    puts "Title?"
    title = gets.chomp.downcase
    if movies[title.to_sym].nil?
        puts "That movie isn't present."
    else
        puts "Rating?"
        rating = gets.chomp
        movies[title.to_sym] = rating.to_i
    end
when 'display'
    movies.each do |movie, rating|
        puts "#{movie}: #{rating}."
    end
when 'delete'
    puts "Deleted!"
else
    puts "Error!"
end


#2

Just noticed I accidentally deleted my case choice statement, took an embarrassingly large amount of time to find lol


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.