Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- movies = {
- Memento: 4,
- American_Beauty: 3,
- Inception: 5
- }
- puts "Enter your choice!"
- puts "Type add to add a movie and it's rating."
- puts "Type update to update a movie rating."
- puts "Type display to show the movie and it's rating."
- puts "Type delete to remove a movie from the list."
- choice = gets.chomp
- case choice
- when "add"
- puts "What is the title of the movie you want to add?"
- title = gets.chomp
- if movies[title.to_sym].nil?
- puts "How would you rate that movie?"
- rating = gets.chomp
- movies[title.to_sym] = rating.to_i
- puts "We have added #{title} with the rating of #{rating}!"
- else
- puts "We already have that movie in the system."
- puts "It's rating is #{rating}"
- end
- when "update"
- puts "What is the title of the movie you want to update?"
- title = gets.chomp
- if movies[title.to_sym].nil?
- puts "Error!"
- else
- puts "How would you rate the movie?"
- rating = gets.chomp
- movies[title.to_sym] = rating.to_i
- puts "We have updated #{title} with the rating of #{rating}!"
- end
- when "display"
- movies. each do |movie, rating|
- puts "#{movie}: #{rating}"
- end
- when "delete"
- puts "What is the title of the movie you want to delete?"
- title = gets.chomp
- if movies[title.to_sym].nil?
- puts "Error!"
- else
- movies.delete(title.to_sym)
- puts "We have deleted #{title} from the list."
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement