Skip to content

Instantly share code, notes, and snippets.

@sylar
Last active September 23, 2016 19:20
Show Gist options
  • Save sylar/79bfb977b119f05c187e53f20b7808ee to your computer and use it in GitHub Desktop.
Save sylar/79bfb977b119f05c187e53f20b7808ee to your computer and use it in GitHub Desktop.
movies={
"The Prestige" => 5,
"Titanic" => 3
}
exists = false
puts 'Write "add" to insert a movies'
choice=gets.chomp
case choice
when "add"
puts "Give me a title!"
title=gets.chomp
puts "Rate the movie"
rating=gets.chomp
movies.each do | movieTitle, movieRating |
if movieTitle == title
exists = true
end
end
if !exists
movies[title] = rating
puts "Rating and name were added"
else
puts "The movie already exists!"
end
puts movies
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment