Album System

Github

A simple Java package system for logging a list of albums that the user owns and albums that the user wants to own.
Forks: 0
Stars: 0
Open issues: 0
Latest tag: None
git clone https://github.com/f13dev/AlbumSystem.git

System domain

The Album Library System holds information regarding a number of artists and their albums. The system should, for each album, have an artist. Each album may also contain a track listing and a year of release. Each album is either marked as owned or wants to own. Each artist on the system should have an artist name and the possibility to hold notes about the artist.

The system administrator may add new artists or albums to the library, mark albums as owned or want to own, add or edit the albums track listing.

Use cases

The Album Library System will provide support to the user by enabling the administrator to do the following:

  1. Add a new album.
    The administrator identifies the artist name, album title and selects whether they own the album or wish to own the album.
  2. List albums.
    The administrator identifies all, an artist or want to/own. The system displays a list of artists and albums that match the criteria.
  3. Remove album.
    The administrator identifies the album. The system removes all links to the given album to remove it from the system.
  4. Add artist.
    The administrator identifies the artist name to add. The system records the new artist.
  5. Mark album as owned.
    The administrator identifies an album. The system records that the album is now owned.
  6. Mark album as not owned.
    The administrator identifies an album. The system records that the album is no longer owned.

Class diagram

Class diagram for the Album System

Class diagram for the Album System

Class descriptions

Package albumcore
Class AlbumCoord – the coordinating class
Attributes
none
Links
private Collection<Album> albums
A collection of all albums on the system
private Coollection<Artist> artists
A collection of all artists on the system
 Protocol
public Collection<Album> getAlbums()
Post-condition: returns albums
public Collection<Artist> getArtists()
Post-condition: returns artists
public Artist getArtist(Album anAlbum)
Post-condition: returns the artist object associated with anAlbum
public String getArtistName(Album anAlbum)
Post-condition: returns the name attribute of the artist associated with anAlbum
public boolean isOnwed(Album anAlbum)
Post-condition: returns the owned attribute associated with anAlbum
public void setOwned(Album anAlbum, boolean isOwned)
Post-condition: sets the value of the owned attribute to the value of isOwned for the album anAlbum
public String getArtistName(Artist anArtist)
Post-condition: returns the name attribute of anArtist
public Collection<Album> getArtistAlbums(Artist anArtist)
Post-condition: returns a collection of album objects associated with anArtist
public void addArtistAlbum(Artist anArtist, Album anAlbum)
Post-condition: the album object anAlbum will be added to the albums collection attribute of anArtist
public void removeArtistAlbum(Artist anArtist, Album anAlbum)
Post-condition: the album anAlbum will be removed from the artist anArtist albums collection
public void newArtist(String aName)
Post-condition: initialises a new Artist object with the given name attribute. The newly created Artist object is added to the AlbumCoord albums collection
public void newAlbum(String aTitle, Artist anArtist, boolean isOwned)
Post-condition: initialises a new Album object with the given title, artist and owned attribtues. The newly created album object is added to the AlbumCoord albums collection
 Class Album – an album on the system
Attributes
private String title
The album title
private boolean owned
Whether the album is owned (true) or not owned (false)
Links
private Artist artist
The artist who plays on the album
Constructors
public Album(String aTitle, Artist anArtist, boolean isOwned)
Post-condition: initialises a new Artist object with the give attribute values and adds the newly created Album object to albums collection of anArtist.
Protocol
public Artist getArtist()
Post-condition: returns the Artist object associated with the receiver
public String getAlbumTitle()
Post-condition: returns the album of the receiver
public boolean getOwned ()
Post-condition: returns true if the album is currently owned, returns false if the album is not currently owned
public void setOwned(boolean isOwned)
Post-condition: sets the owned attribute of the receiver to the value of isOwned
public String getArtistName()
Post-condition: returns the name attribute of the artist object associated with the receiver
 Class  Artist – an artist on the system
Attributes
private String title
The album title
Links
private String name
The name of the artist
Constructors
Public Album(String aName)
Post-condition: initialises a new Artist object with the given name attribute
Protocol
public String getName()
Post-condition: returns name
public Collection getAlbums()
Post-condition: returns albums
public void addAlbum(Album anAlbum)
Post-condition: anAlbum is added to the albums collection of the receiver
public void removeAlbum(Album anAlbum)
Post-condition: anAlbum is removed from the albums collection of the receiver

Invariants

  1. All Album objects associated with an Artist object have an artist attribute that points to the same Artist object
  2. Only one Album object may exist with the same title and Artist attribute
  3. Only one Artist object may exist with a given name

Dynamic models

Sequence diagram depicting the creation of a new Artist object names "Metallica".

Sequence diagram depicting the creation of a new Artist object names “Metallica”.

Sequence diagram depicting the creation of a new Album object titled "The Black Album", linked to the Artist object named "Metallica".

Sequence diagram depicting the creation of a new Album object titled “The Black Album”, linked to the Artist object named “Metallica”.

Sequence diagram depicting the getAlbums() method for artist5.

Sequence diagram depicting the getAlbums() method for artist5.

The caption

The caption

Code

File: AlbumCord constructor

package AlbumCore;

Class AlbumCord()
{
  /*
   * Instance variables to store a set of artists and a set of albums
   */
  private Set<Artist> artists;
  private Set<Album> albums;

  /**
    * Initialises a new instance of AlbumCord with empty
    * collections for albums and artists.
    */
  public AlbumCord()
  {
    this.albums = new HashSet<>();
    this.artists = new HashSet<>();
  }
}

Notes

JavaDoc