Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Reads in an Album from a file and then prints all the album
- # to the terminal
- def main
- music_file = File.new("album.txt", "r")
- album = read_album(music_file)
- music_file.close()
- search_string = read_string("Enter the track name you wish to find: ")
- index = search_for_track_name(album.tracks, search_string)
- if index > -1
- puts "Found " + album.tracks[index].name + " at " + index.to_s
- else
- puts "Entry not Found"
- end
- end
- main
- def search_for_track_name(tracks, search_string)
- index = 0
- count = music_file.gets()
- while (index < count)
- if (tracks[index] == search_string)
- return found_index = -1
- end
- index += 1
- end
- found_index
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement