Question: Write a fully - documented class named Playlist that stores all SongRecord objects that belong to a particular playlist. The SongRecord objects should be stored
Write a fullydocumented class named Playlist that stores all SongRecord objects that belong to a particular playlist. The SongRecord objects should be stored in an array. There should be a maximum of SongRecord objects allowed, a number which should be defined as a final variable. The class will be based on the following ADT specification:
public void addSongSongRecord song, int position
Parameters:
song the new SongRecord object to add to this Playlist
position the position in the playlist where the song will be inserted
Preconditions:
This SongRecord object has been instantiated and position songscurrentlyinplaylist The number of SongRecord objects in this Playlist is less than maxsongs.
Postcondition:
The new SongRecord is now stored at the desired position in the Playlist. All SongRecords that were originally in positions greater than or equal to position are moved back one position. Ex: If there are songs in a Playlist, positions and you insert a new SongRecord at position the new SongRecord will now be at position the SongRecord that was at position will be moved to position and the SongRecord that was at position will be moved to position
Throws:
IllegalArgumentException
Indicates that position is not within the valid range.
FullPlaylistException
Indicates that there is no more room inside of the Playlist to store the new SongRecord object.
Note :
position refers to the position in the Playlist and not the position inside the array.
Note :
Inserting a song to position songscurrentlyinplaylist is effectively the same as adding a song to the end of the Playlist.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
