Skip to content

Instantly share code, notes, and snippets.

@msmith7904
Created October 22, 2014 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msmith7904/1174e1cfb26b9313b16d to your computer and use it in GitHub Desktop.
Save msmith7904/1174e1cfb26b9313b16d to your computer and use it in GitHub Desktop.
trains = {
"L Train" => "8th Ave, 6th Ave, Union Square, 3rd Ave, 1st Ave, Bedford Ave",
"N Train" => "Times Square, Herald Square, 28th St, 23rd St - HMH Nexus, Union Square, 8th Ave",
"6 Train" => "Grand Central, 33rd St, 28th St, 23rd St, Union Square, Astor Place"
}
loop do
puts "To view all train lines, type lines."
puts "To view all stations for line, type stations."
puts "To add a train line, type add."
puts "To quit, type quit."
puts "Please make your selection."
choice = gets.chomp.downcase
if choice == "lines"
trains.each_key do |key|
puts key
end
elsif choice == "stations"
trains.each_key do |key|
puts key
end
puts "Please make your selection."
train_choice = gets.chomp
trains.each do |key, value|
if train_choice == key
puts "You picked the #{key}."
puts "The stations are #{value}"
end
end
elsif choice == "add"
puts "What line would you like to add?"
new_line = gets.chomp
puts "What are the stations?"
new_stations = gets.chomp
trains[new_line] = new_stations
puts "You added the #{new_line}."
puts "The stations are #{new_stations}."
elsif choice == "quit"
puts "Thank You. Have a nice day."
break
else
puts "That's not an option!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment