Music Playlist Manager in Java: Explanation & Practice

Create a playlist management system

Problem summary

Create Song and Playlist classes. Playlist can add, remove songs and calculate total duration.

Starter code

// Song: name, artist, durationSeconds
// Playlist: name, list of songs
// Methods: addSong, removeSong, totalDuration

public class Main {
    public static void main(String[] args) {
        // Create playlist, add songs, print total duration
        // Print: Total: <minutes>:<seconds>
    }
}

Expected output and test cases

  • Multiple songs
    Total: 10:30
  • Single song
    Total: 3:45
  • Empty playlist
    Total: 0:00

Hints

  1. Store songs in ArrayList
  2. Sum all durations
  3. Format as MM:SS

Related OOP Basics exercises

Practice all OOP Basics exercises · Run this idea in the Java compiler