You are on page 1of 3

Implement the following class relationships.

One Music album contains many


songs. Class outline is given below. Use package “com” to build your
solution.

1 1..*

contains
MusicAlbum Song
Write the following methods in MusicAlbum class.
public void addSong(Song song){
/*
This method returns adds the new song into the list
*/
}
public int getTotalDuration(){
/*
Iterate through the list of songs and find the sum of duration.
*/
}
public boolean searchSong(String songTitle){
/*
Search for the song with the given title and return true if found.
*/
}
• Write a class Test with main() method.
• Create a MusicAlbum object. Create 3 Song objects and add to the album.
• Test all the methods written in MusicAlbum class

You might also like