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 fully-documented 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 50 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 addSong(SongRecord 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 1< position < songs_currently_in_playlist +1. The number of SongRecord objects in this Playlist is less than max_songs.
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 5 songs in a Playlist, positions 1-5, and you insert a new SongRecord at position 4, the new SongRecord will now be at position 4, the SongRecord that was at position 4 will be moved to position 5, and the SongRecord that was at position 5 will be moved to position 6).
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 1:
position refers to the position in the Playlist and not the position inside the array.
Note 2:
Inserting a song to position (songs_currently_in_playlist +1) 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!