← Unit 3 · all exercises
Saved in this browser only

Describing itself

Write a Song class holding a title and a length in seconds. describe returns text like "Yesterday (125s)" — the title, a space, then the seconds in brackets with an s.

class Song { Song(String title, int seconds); String describe(); }

Song.java
Loading editor…
Results

Examples

  • new Song("Yesterday", 125).describe() → Yesterday (125s)
  • new Song("Hey", 5).describe() → Hey (5s)

There are also 2 hidden tests you can't see. Solve the problem, not the examples.