Question: I'm having some trouble finding out how to construct a method Playlist(String filename) to have it contain each line of information given to it from
I'm having some trouble finding out how to construct a method "Playlist(String filename)" to have it contain each line of information given to it from a file that is supplied by an online auto-grader when compiling and testing. I've already made a separate class named "Song" which takes a string of information about a song i.e. "Roundabout,Yes,14:50" and stores it, however, the Playlist class is given a filename to access which I'm not sure how to do.

Playlist Class: Each Playlist stores a reference to an ArrayList of Songs. We want to protect these Songs so they can only be modified by methods of the Playlist class. In order to accomplish this, any song must be copied before it is added or returned from a Playlist. Otherwise, the calling method will have a reference to mutable private data. Below are descriptions of the methods of the Playlist class: Playlist(): Construct an empty Playlist. Playlist(String filename): Construct a Playlist from a file of info Strings. The Playlist should contain a Song for every line of the file, and the order of the Songs should match the file
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
