lib/app/models/cli.rb
def update_or_delete_trip(trips)
    while true
        puts "\nPlease select the following options: (1-5) "
        puts "1. View the Information for A Trip"
        puts "2. View All Stop Information for a Trip"
        puts "3. Update a Trip"
        puts "4. Delete a Trip and All of its Stops"
        puts "5. Go Back to the Main Menu"
        user_input = gets.chomp
        case user_input
        when'1'
            system "clear"
            puts "Please choose a trip to view its information: (1 - #{trips.length})"
            trip=choose_trip(trips)
            puts "\nHere is the trip information for #{trip.name}"
            trip.view_information
        when'2'
            system "clear"
            puts "Please choose a trip to view all its Stops: (1 - #{trips.length})"
            trip = choose_trip(trips)
            puts "\nHere are all the stops for your trip #{trip.name}"
            trip.stop_information
        when'3'
            system "clear"
            puts "Please choose a trip to update: (1 - #{trips.length})"
            trip = choose_trip(trips)
            update_trip(trip)
        when'4'
            system "clear"
            puts "Please choose a trip to delete: (1 - #{trips.length})"
            delete_trip_stops(trips)
            go_back_to_menu?($user)
        when'5'
            system "clear"
            main_menu($user)
        else
            system "clear"
            puts "Invalid Response. Please enter a number (1-5)"
            update_or_delete_trip(trips)
        end
    end
end
#USER STORY 2, Update/Delete existing trips
USER STORY 2, Update/Delete existing trips
USER STORY 2 Update / Delete existing trips
def update_or_delete_trip(trips)
    while true
        puts "\nPlease select the following options: (1-5) "
        puts "1. View the Information for A Trip"
        puts "2. View All Stop Information for a Trip"
        puts "3. Update a Trip"
        puts "4. Delete a Trip and All of its Stops"
        puts "5. Go Back to the Main Menu"
        user_input = gets.chomp
        case user_input
        when'1'
            system "clear"
            puts "Please choose a trip to view its information: (1 - #{trips.length})"
            trip=choose_trip(trips)
            puts "\nHere is the trip information for #{trip.name}"
            trip.view_information
        when'2'
            system "clear"
            puts "Please choose a trip to view all its Stops: (1 - #{trips.length})"
            trip = choose_trip(trips)
            puts "\nHere are all the stops for your trip #{trip.name}"
            trip.stop_information
        when'3'
            system "clear"
            puts "Please choose a trip to update: (1 - #{trips.length})"
            trip = choose_trip(trips)
            update_trip(trip)
        when'4'
            system "clear"
            puts "Please choose a trip to delete: (1 - #{trips.length})"
            delete_trip_stops(trips)
            go_back_to_menu?($user)
        when'5'
            system "clear"
            main_menu($user)
        else
            system "clear"
            puts "Invalid Response. Please enter a number (1-5)"
            update_or_delete_trip(trips)
        end
    end
end
def update_or_delete_trip ( trips ) while true puts "\nPlease select the following options: (1-5) " puts "1. View the Information for A Trip" puts "2. View All Stop Information for a Trip" puts "3. Update a Trip" puts "4. Delete a Trip and All of its Stops" puts "5. Go Back to the Main Menu" user_input = gets . chomp case user_input when '1' system "clear" puts "Please choose a trip to view its information: (1 - #{trips.length})" trip = choose_trip ( trips ) puts "\nHere is the trip information for #{trip.name}" trip . view_information when '2' system "clear" puts "Please choose a trip to view all its Stops: (1 - #{trips.length})" trip = choose_trip ( trips ) puts "\nHere are all the stops for your trip #{trip.name}" trip . stop_information when '3' system "clear" puts "Please choose a trip to update: (1 - #{trips.length})" trip = choose_trip ( trips ) update_trip ( trip ) when '4' system "clear" puts "Please choose a trip to delete: (1 - #{trips.length})" delete_trip_stops ( trips ) go_back_to_menu? ( $user ) when '5' system "clear" main_menu ( $user ) else system "clear" puts "Invalid Response. Please enter a number (1-5)" update_or_delete_trip ( trips ) end end end
USER STORY 2, Update/Delete existing trips
USER STORY 2 Update / Delete existing trips
trips