# Unit 4 – Advanced Demo: Playlist

This demo extends the Basic Playlist into a genre-tagged playlist. The
platform defines a fixed set of genres — Pop Music, Rock & Roll,
Jazz & Soul, Classical & Orchestral — and every track must be tagged
with one of them. The genres themselves never change; only the tracks
come and go.

## Setting up

1. Compile `Playlist`.
2. Create a `Playlist("Road Trip")` object on the Object Bench.

## Experimenting

3. Call `addTrack("Mr Brightside", "rock")` and
   `addTrack("Waterloo", "pop")`.
4. Call `printAll()` — each track appears with its full genre label in
   brackets.
5. Try `addTrack("Blue in Green", "metal")` — BlueJ reports an
   `IllegalArgumentException` because `"metal"` is not a recognised genre.
6. Call `hasGenre("rock")` — returns `true`. Call `hasGenre("metal")` —
   returns `false`.
7. Call `removeTrack("Waterloo")`, then `printAll()` again — only one
   track remains; the genre list is unchanged.

## What to look at in the code

8. `genres` and `genreLabels` are declared as `List` and `Map` — not
   `Mutable`. They are initialised once and can never be changed.
9. `tracks` and `trackGenres` are declared as `MutableList` and
   `MutableMap` — the same types as in the Basic demo — and remain
   fully changeable.
10. `addTrack()` calls `require()` before touching any collection.
    `require()` throws `IllegalArgumentException` if its condition is
    false — a concise way to enforce platform rules without writing an
    `if`/`else`.
