Lesson 8 Display


#1

movies={
poop: 5,
memento: 4,
Primer: 4

}

puts "What do you want to do?"
input=gets.chomp

case input
when "add"
puts "What movie would you like to add?"
title=gets.chomp
title=title.to_sym
puts "How would you rate this movie, out of 5?"
rating=gets.chomp
rating=rating.to_i
if movies[title].nil?
movies[title]=rating
puts "I've added #{title} to your list."
end

when "update"
puts "What title would you like to update?"
title=gets.chomp
if movies[title.to_sym].nil?
puts "This movie doesn't exist in your database"
else
puts "what new rating would you give this movie?"
rating=gets.chomp
rating=rating.to_i
movies[title.to_sym]=rating
puts "I've updated your selection"
end
when 'display'
movies.each do |movie, rating|
puts "#{movie}: #{rating}"
end
when "delete"
puts "Deleted!"
else
puts "Error!"
end
puts movies

I keep getting the same "make sure to test your program using 'display' " message, even though it works perfectly. My code is the exact same as the code they wrote in the beginning of this project. It has to be bugged, and I can't pass it. I'm so beyond frustrated at this point.


#2

Hi your code works fine, just when you save & submit you should type display on the console and then click one Enter


#3

I think your code works fine. Did you type display when it prompts the user what he wants to do? Otherwise try with another browser.


#4

I'm getting the same problem...

movies = { Big_Fish: 5.0 }

print "Choose an option:"
choice = gets.chomp

case choice
when "add"
puts "Insert your favorite movie: "
title = gets.chomp.to_sym
if movies[title.to_sym] == nil
puts "Insert evaluation: "
rating = gets.chomp.to_i
movies[title.to_sym] = rating
puts movies
else
puts "Movie already exists!"
end
when "update"
puts "Insert movie name to update: "
title = gets.chomp.to_sym
if movies[title.to_sym] == nil
puts "Movie does not exists."
else
puts "Insert evaluation: "
movies[title.to_sym] = gets.chomp.to_i
puts movies
end
when "display"
movies.each { |movie,rating| puts "#{movie}: #{rating}" }
when "delete"
puts "Deleted!"
else
puts "Error!"
end

I'm typing display when the program ask an option. But Academy returns: Ops, tente outra vez. It looks like your 'puts' doesn't include Big_Fish: 5.0.


#5

Be careful with your spacing! The output format should be exactly like this: #{movie}: #{rating}, which should result in something like the below.There is a space between movie and rating.


#6