lib/nswparks/cli.rb
# Puts out information on a selected NSW National Park using #park_list
Puts out information on a selected NSW National Park using #park_list
Puts out information on a selected NSW National Park using #park_list
def park_info
    park_list
    park_no = 0
    puts ""
    puts "Enter the number for the park you are interested in:"
    park_no = gets.strip.to_i
    while !(park_no.is_a? Integer) || park_no < 1 || park_no > NSWParks::Nsw_parks.all.size
      park_list
      park_no = NSWParks::Nsw_parks.valid_input?
    end  
    puts ""
    puts NSWParks::Nsw_parks.all[park_no - 1].park_name  
    puts ""
    puts "----------------------------------------------------------------------------------------"
    NSWParks::Nsw_parks.park_info(park_no)  
  end
def park_info park_list park_no = 0 puts "" puts "Enter the number for the park you are interested in:" park_no = gets . strip . to_i while ! ( park_no . is_a? Integer ) || park_no < 1 || park_no > NSWParks :: Nsw_parks . all . size park_list park_no = NSWParks :: Nsw_parks . valid_input? end puts "" puts NSWParks :: Nsw_parks . all [ park_no - 1 ] . park_name puts "" puts "----------------------------------------------------------------------------------------" NSWParks :: Nsw_parks . park_info ( park_no ) end
Puts out information on a selected NSW National Park using #park_list
Puts out information on a selected NSW National Park using #park_list
# Validate user input - input must be an integer and exist in the list # Gives returned park info a heading of the park name # Puts out park info using Nsw_parks #park_info