Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # reads in a single track from the given file.
- def read_album a_file
- title = a_file.gets()
- artist = a_file.gets()
- genre = a_file.gets()
- tracks = a_file.gets()
- count = tracks.to_i
- count.times do
- read_track (a_file)
- end
- return Album.new(title, artist, genre, tracks)
- end
- # Returns an array of tracks read from the given file
- def read_albums music_file
- count = music_file.gets().to_i
- albums = Array.new
- i = 0
- # Put a while loop here which increments an index to read the tracks
- while i < count
- album = read_album(music_file)
- albums << album
- i += 1
- end
- return albums
- end
- main
- #calling a file albums
- a_file = File.new("albums.txt", "r")
- temp_albums = read_albums(a_file).to_s
- #in this line i want to access the element albums thats returned from above method read_albums
- puts $genre_names[temp_albums.genre]
- end
- main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement