---
# System prepended metadata

title: 'Poor man''s Spotify :guitar:'

---

# Poor man's Spotify :guitar: 

## Playable
Идва ред и на съдържанието, предоставяно от платформата.
Създайте два класа - `Audio` и `Video`*, които имплементират интерфейса `Playable`:
```java=
package bg.sofia.uni.fmi.mjt.spotify.playable;

public interface Playable {

    /**
     * Simulates playing activity of the content, which results in increment of the total plays count,
     * and returns the initial message displayed to the user. The message has the following format:
     * "Currently playing <type> content: <content_name>", where <type> is the type of the playable content, and
     * <content_name> is its name.
     */
    String play();

    /**
     * Returns the total count of times the content has been played.
     */
    int getTotalPlays();

    /**
     * Returns the title of the playable.
     */
    String getTitle();

    /**
     * Returns the artist of the playable.
     */
    String getArtist();

    /**
     * Returns the publishing year of the playable.
     */
    int getYear();

    /**
     * Returns the duration of the playable.
     */
    double getDuration();

}
```

И двата класа имат конструктори с параметри - `(String title, String artist, int year, double duration)`.

*От около година Spotify поддържа и video streaming - https://support.spotify.com/us/article/videos/

### Playlist

Spotify предлага и функционалност за създаване и управление на плейлисти.
Създайте клас `UserPlaylist`, който има конструктор `public UserPlaylist(String name)` и имплементира интерфейса `Playlist`:

```java=
package bg.sofia.uni.fmi.mjt.spotify.playlist;

import bg.sofia.uni.fmi.mjt.spotify.playable.Playable;

public interface Playlist {
    
    static final int MAX_SIZE = 20;

    /**
     * Adds the given playable content to the playlist.
     * @throws PlaylistCapacityExceededException when the playlist has exceeded its predefined capacity MAX_SIZE.
     */
    void add(Playable playable) throws PlaylistCapacityExceededException;

    /**
     * Returns the name of the playlist.
     */
    String getName();
}
```

За управление на плейлисти използваме т.нар. Library:
```java=
package bg.sofia.uni.fmi.mjt.spotify.library;

import bg.sofia.uni.fmi.mjt.spotify.playlist.Playlist;
import bg.sofia.uni.fmi.mjt.spotify.playlist.PlaylistNotFoundException;

public interface Library {

    static final int MAX_PLAYLISTS = 21;

    /**
     * Adds the provided playlist to the library.
     * @throws LibraryCapacityExceededException when the given library capacity is exceeded.
     */
    void add(Playlist playlist) throws LibraryCapacityExceededException;

    /**
     * Removes the playlist with the given name from the library.
     * @throws EmptyLibraryException if the library is still empty.
     * @throws PlaylistNotFoundException if the playlist with the given name is not present in the library.
     * @throws IllegalArgumentException if the given playlist name matches the default liked content playlist name.
     */
    void remove(String name) throws LibraryCapacityExceededException, EmptyLibraryException, PlaylistNotFoundException;

    /**
     * Returns the default "liked songs" playlist from the library.
     */
    Playlist getLikedSongs();

}
```

Имплементация на Library е класа `UserLibrary`, който има default конструктор.
Важни уточнения за user library:
- Всеки потребител задължително има плейлист, наречен liked - той съдържа всички песни, които някога са били харесани.