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
- Store songs in ArrayList
- Sum all durations
- Format as MM:SS
Related OOP Basics exercises
- Practice Inventory Management in Java
- Practice Rational Number Class in Java
- Practice Singleton Pattern in Java
Practice all OOP Basics exercises · Run this idea in the Java compiler