// A PlayList has a collection of Tracks. In addition, playlists also have a name // and a description, Eg. a playlist by the name "MJ All time hits" with the // description "The greatest tracks by the King of Pop" has a collection of Tracks // each a song by Michael Jackson. // An additional feature of your playlist will be that you can search for tracks // by title and by artist. These search commands can be one of two types (examples // below) - // 1. Exact Search: // searchByExactTitle("Dark Side of the Moon") will return the single Track // among all the tracks in this PlayList that have their title as "Dark Side of the // Moon". If no such track exists, then null is returned. // 2. Approximate (or Substring) Search // searchByTitle("moon") will return all the Tracks in this PlayList that have the // word "moon" in their title. Note that since there can be more than one such // Track, the return value is a new PlayList with only the correct tracks. For // example, PlayList p2 = p1.searchByTitle("moon") then p2 is a playlist // whose tracks are the tracks that were in p1 and had the word "moon" in their // name. Note that the chosen tracks will now be present both in playlist p1 and // p2. The name property of p2, should be the search expression ("moon" in this // case), and description should indicate that it was a search result ("search for // for title: moon" in this case). import java.util.ArrayList; public class PlayList{ // The instance variables of the PlayList - the name, description, and collection // of tracks in the playlist. // The constructor for a playlist... create an empty playlist with the name // and description provided public PlayList(String playListName, String description){} // Access methods - get the name, description, tracks, and the number of tracks public String getName() { return ""; } public String getDescription() { return ""; } public ArrayList getTracks() { return null; } public int getNumberOfTracks() { return 0; } // Express the contents of the playlist as a single string - the string should // include the name of the playlist, its description and the details of each of // the tracks in the playlist. Remember that your string can also include // newlines ("\n") so that the string is more readable. // Note: This method sould NOT print the string, but return the string. public String toString() { return ""; } // Commands // Add a single track to the collection of tracks in this playlist. // Check if the parameter is not a null parameter. public void addTrack(Track track) {} // Merge two playlists. Add the tracks in the other playlist to the tracks in this // playlist. Retain the name and description of this playlist. // Note: You should NOT create a new PlayList. The tracks in the other playlist // will now be present in both this and the other playlist. public void combinePlayList(PlayList other) {} // Search Methods // Search for a track in this PlayList whose title exactly matches the // title exactTitle. If there are multiple tracks with that name, return any // one. Return null if there is no such track. public Track searchByExactTitle(String exactTitle){ return null; } // Search for the tracks in this PlayList such that titleSubString is a // part of the title of the track. Return a new PlayList that has only // the tracks that satisfy this condition. The name and description of the // newly created PlayList are as described at the top of this file. // Observe that there might not be any tracks which satisfy this search. // In that case the return playlist will have no tracks (but still has a // valid name and description). public PlayList searchByTitle(String titleSubString){ return null; } // Search for the tracks such that artistSubString is a part of the artist name // for the track. The rest of the description is similar to that of the // searchByTitle method. public PlayList searchByAritist(String artistSubString){ return null; } }