Plz do in Java
For our third lab, we will write a pair of classes that do not have this limitation: Song and Playlist. Playlist objects store a list of Song objects that can be modified in various ways. Most importantly, the state of a Playlist can be saved and loaded from a text file, so we can keep track of our music collection even after our program stops! Class Diagram:1 0..* 0..1 Song -title: String -artist: String -minutes: int -seconds: int -numPlays: int -IDX TITLE = 0: int -IDX ARTIST = 1: int -IDX LENGTH = 2: int -IDX NUM PLAYS = 3: int +Song(info: String) +Song (other: Song) +getTitle(): String +getArtist(): String +getMinutes(): int +getSeconds(): int +getLength(): String +getNumPlays (): int +incrementPlays (): void +toString(): String Playlist -songs: ArrayList
+Playlist() +Playlist(filename: String) -load(filename: String): void +save(filename: String): void +addSong(song: Song): void +addSong(index: int, song: Song): void +addSongs (filename: String): void +getSong(index: int): Song +numSongs(): int +playSong(index: int): void +remove Song(index: int): Song +toString(): String +favoriteArtist(): String +totalPlaytime(): String Song Class: Each Song has a title, artist, length, and play count. The length is stored in two fields: minutes and seconds. Songs can be constructed from either an info String or another Song object. Info Strings have the following format: ",,:", which is the value of the artist field. Optionally, an info String may have a fourth value that specifies the number of times a song has been played: ",,:," If this value is absent, initialize numPlays to 0. To illustrate this format, consider the following info String: "Ten Years Gone, Led Zeppelin, 6:31" A Song constructed from this String stores "Ten Years Gone" in the title field, "Led Zeppelin in the artist field, 6 in the minutes field, and 31 in the seconds field. The info String does not have a fourth value, so the object stores O in the numPlays field. Below are descriptions of some methods of the Song class: Song(Song other): This is known as a "copy constructor. It creates a new song that is a copy of an existing Song. That is, it initializes the fields of the new Song to the values stored in the given Song. The utility of this method will become clear when writing the Playlist class. .getLength(): Return the song length in the format of an info String: ": :: " The number of minutes and seconds should each be a number between 0 and 59. If the number of hours is 0, use this format instead: ": +Playlist() +Playlist(filename: String) -load(filename: String): void +save(filename: String): void +addSong(song: Song): void +addSong(index: int, song: Song): void +addSongs (filename: String): void +getSong(index: int): Song +numSongs(): int +playSong(index: int): void +remove Song(index: int): Song +toString(): String +favoriteArtist(): String +totalPlaytime(): String Song Class: Each Song has a title, artist, length, and play count. The length is stored in two fields: minutes and seconds. Songs can be constructed from either an info String or another Song object. Info Strings have the following format: ",,:", which is the value of the artist field. Optionally, an info String may have a fourth value that specifies the number of times a song has been played: ",,:," If this value is absent, initialize numPlays to 0. To illustrate this format, consider the following info String: "Ten Years Gone, Led Zeppelin, 6:31" A Song constructed from this String stores "Ten Years Gone" in the title field, "Led Zeppelin in the artist field, 6 in the minutes field, and 31 in the seconds field. The info String does not have a fourth value, so the object stores O in the numPlays field. Below are descriptions of some methods of the Song class: Song(Song other): This is known as a "copy constructor. It creates a new song that is a copy of an existing Song. That is, it initializes the fields of the new Song to the values stored in the given Song. The utility of this method will become clear when writing the Playlist class. .getLength(): Return the song length in the format of an info String: ": :: " The number of minutes and seconds should each be a number between 0 and 59. If the number of hours is 0, use this format instead: ":