A Night at The Movies (Prompting Redux!)

ruby

#1

Hi! Would appreciate it if someone can help explain what is wrong with my code. I looked at all the explanation provided in the forum but non seemed to work. I kept getting this "Oops, try again. Did you create a variable called title?".

movies = {
Curious_Case_of_Benjamin_Button: 5,
Dark_Knight: 5,
Spiderman: 4
}

puts "What do you want to do (add, update, display or delete)?"
choice = gets.chomp

case choice
when "add"
puts "What is the movie title?"
movie_title = gets.chomp
puts "What is the rating of the movie?"
movie_rating = gets.chomp
movies = Hash.new
movies[movie_title] = movie_rating
puts "The movie #{movie_title} has a rating of #{movie_rating}."
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end


#2

Did you try with just title?

title = gets.chomp

#3
  1. movies = Hash.new("movie_title" => movie_rating) and
  2. Remove: movies[movie_title] = movie_rating - this works

OR

Remove: movies = Hash.new and
Convert movies[movies_title] to movies["movies_title"] - not sure if this works but you can try


#4