Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA. This is the second part of the program that I'm working on. I've already set up a constructor for the class but I'm struggling

JAVA. This is the second part of the program that I'm working on. I've already set up a constructor for the class but I'm struggling with using a BufferedReader to access a file that is given by an auto-grader.

image text in transcribed

load(String filename): Read a file of info Strings with the given name. For each line of the file, create a Song and add it to the end of the Playlist. This method is intended to be a helper method for Playlist(String filename) and addSongs(String filename). save(String filename): Save the output of toString() to a file with the given name. (Overwrite the contents of the file if it already exists.) .addSong(Song song): Add a copy of the given Song to the end of the Playlist. .addSong(int index, Song song): Add a copy of the given Song to the Playlist at the given index. addSongs(String filename): A public version of the method Load(String filename). .getSong(int index): Return a copy of the Song with the given index. numSongs(): Return the number of Songs in the Playlist. playSong(int index): Increment the number of plays of the Song with the given index. remove Song(int index): Remove and return the song with the given index. (It is not necessary to return a copy.) toString(): Return a String with the values of the fields of every Song in the Playlist. Create the String by calling toString() on each Song and joining the output with newline characters. (Do not terminate the String with a newline character.) For example, if a Playlist contains Songs constructed with these info Strings: "So What, Miles Davis, 9:22" "Firth of Fifth, Genesis,9:35" Then calling toString() on the Playlist should return this String: "So What, Miles Davis, 9:22 Firth of Fifth, Genesis, 9:35" favorite Artist(): Return the artist that appears most frequently in the Playlist. If the Playlist is empty, return null. totalPlaytime(): Return the total length of all the songs in the following format: "::::::

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

Entity Alignment Concepts Recent Advances And Novel Approaches

Authors: Xiang Zhao ,Weixin Zeng ,Jiuyang Tang

1st Edition

9819942527, 978-9819942527

More Books

Students also viewed these Databases questions