movies = {
Tron: 4,
Jaws: 3,
Inception: 5
}
puts "Enter a choice ('add', 'update', 'display', 'delete'):"
choice = gets.chomp.downcase
#puts choice
case choice
when 'add'
puts "Enter the movie title you'ld like to add:"
title = gets.chomp
if movies[title.to_sym] === nil
puts "Enter the movie's rating:"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
#test
puts movies
puts "Movie title and rating has been added!"
else
puts movies
puts "Movie already exists!"
end
when 'update'
puts "Enter the movie title you'ld like to update:"
title = gets.chomp
if movies[title.to_sym] === nil
puts movies
puts "Movie doesn't exist!"
else
puts movies
puts "Enter the movie's updated rating:"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
#test
puts movies
puts "Movie rating has been updated!"
end
when 'display'
puts "Movies!"
when 'delete'
puts "Deleted!"
else
puts "Error!"
end
No comments:
Post a Comment