TOPIC 2: Music Library Management
(File name: majorAssignmentTopic2.zip)
In the problem, there are songs by artists (artists can be bands or solo artists), which can be
singles or belong to albums. You are required to create song catalogues, libraries, or playlists
with the ability to go to the previous song or the next song and shuffle play.
Implementation and testing
Unit testing
The project includes diverse JUnit tests for each class, ensuring robust unit tests across various
scenarios. In order to ensure that the application behaves as expected in a wide range of
situations, we have tested both typical and edge cases.
Artist Class: Tests for adding albums and singles to an artist, verifying the correct retrieval of
artist information. It also has edge cases, including attempting to add multiple albums to an
artist and verifying that they are handled correctly.
Album Class: We implemented tests for adding songs to the albums and verifying that the
album correctly tracks the number of songs and the artist. We implemented boundary cases
for handling albums with no songs, too.
Song Class: Has tests for verifying the creation of songs, checking that the correct artist and
album are associated with the song, and ensuring duration is correctly stored while including
testing songs that are part of an album and those singles as edge cases.
Playlist Class: Tests implemented the following functions: for adding songs to playlists,
navigating through songs through the nextSong() and previousSong() methods, and the
shuffle feature. Also tested are edge cases that include empty playlists, handling single songs
in playlists, and handling circular navigation.
LibraryService and PlaylistService Classes: Contains extensive unit tests covering adding
artists, albums and songs to the library and also trying to retrieve non-existent albums or
artists whilst verifying that null values are correctly returned without causing errors.
Functionality
The Music Library Management System provides a variety of core features for managing a
music collection, including the following functionality:
Artists: Users can add artists (either solo artists or bands) to the system. Each artist can have
multiple albums and singles.
Albums: Users can add albums to the system, with each album linked to an artist and
containing multiple songs. Albums are stored and retrieved within the library.
Songs: Users can add songs to albums or single songs directly to artists. Each song stores its
title, artist, duration, and (optionally) its album.
Playlists: Users can create playlists, add songs, shuffle the playlist, and navigate through the
songs using both nextSong() and previousSong() methods. Playlists support circular
navigation, meaning that when the last song is reached, the next song played will loop back
to the first song.
Library Display: The music library management system can display all artists, albums, and
songs in the library
Search: Users can search for artists, albums, or songs by title or name.
Command-line Interaction: The system operates in a command-line interface, allowing
users to interact with the library via a menu. Each feature can be accessed through simple
menu options, ensuring ease of use.
Scope
At least one class contains an object(s) of another user-defined class
The Album class contains an Artist object, creating a direct relationship between an album and
its artist. This allows for precise data modelling, as each album is directly associated with a
specific artist, ensuring that the system can accurately represent music collections.
At least one class contains an ArrayList of object(s) of another user-defined class.
The Artist class contains an ArrayList < Album>¿, representing all the albums that the artist has
created. Similarly, it contains an ArrayList < Song>¿ to track singles. On the other hand, the
Playlist class contains an ArrayList < Song>¿ , representing all songs in that playlist, for easier
playlist management and navigation.
At least one instance of recursive data structure being used
ArrayLists to Recursive structure: Initially, ArrayListswere implemented, allowing a playlist to
contain multiple songs that could be shuffled, had the next and previous function, and could
display all the songs in the playlist. The migration to a recursive structure for the playlists is still
in progress. This will allow a playlist to contain a list of songs and a list of other playlists, thus
forming a recursive tree structure.
File I/O
The file I/O system has been planned and is currently in progress:
Save and load functionality: The project will support saving and loading the music library and
playlists to/from a file, ensuring the system's state can persist between sessions. It will be
included in the next submission. Using Java Serialization, we will store all the library and
playlist data in a . dat file, which can be loaded when the program starts.
Music Library yUML class diagrams
Figure 1: A class diagram containing all classes, including libraryService (for managing the catalogue)
and playlistService (for playlist manipulation).
Figure 2: A simplified yuml class diagram depicting the classes, methods, relationship
In-Progress Work:
Adding error handling for invalid inputs: We are working on input validation throughout the
application to handle invalid inputs more gracefully.
Implementing save/load functionality for playlists and songs using files: Plans are in motion to
add functionality to save and load data from files using Java Serialization.
Future Enhancements:
Graphical User Interface (GUI): Build a JavaFX-based GUI to make the system more user-
friendly.
We are continuing to refine the error handling.
I am testing the save/load functionality.