-name:String
-duration: int
+Song()
+Song(name:String,duration:int)
+getName():String
+getDuration ():int
+toString():String
+compareTo(Object o):int
Song () - default constructor
Song(name:String, duration:int) - parameterized constructor, which sets values to name, and duration.
If the duration less than 1 then set to 1. The name in uppercase.
getName():String - return name
getDuration ():int - return duration.
toString():String - return the string format of the Song:name, duration
compareTo(Object o):int - sort the songs in ascending order by name
Write a class named SongList which extends from TreeSet (TreeSet is a collection) with the following information :
Where:
addSong(Song song): void - add a new song to the SongList
+addSong(Song song): void
+getSongMax Duration (): Song
+printSongList(): void
Zoom
getSongMaxDuration():Song song with the longest duration.return the
printSongList(): void - prints a list of songs in ascending order by name
Song List
+ 100%
Close