Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions