OOP_IO-2x_2023-mirror/Java/lab_6/Track.kt

28 lines
822 B
Kotlin
Raw Normal View History

2023-06-07 15:37:53 +03:00
package OOP.Java.lab_6
import kotlin.time.Duration
2023-06-10 20:47:59 +03:00
/**
* Represents a track on an album.
*
* @param numberInAlbum The position of the track on the album.
* @param trackName The name of the track.
* @param feature The featured artist(s) in the track (nullable if no featured artist).
* @param duration The [Duration] of the track.
*/
2023-06-07 15:37:53 +03:00
open class Track(val numberInAlbum: Int, val trackName: String, val feature: String?, val duration: Duration) {
2023-06-10 20:47:59 +03:00
/**
* The style or genre of the track.
*/
2023-06-07 15:37:53 +03:00
open val style = ""
2023-06-10 20:47:59 +03:00
2023-06-07 15:37:53 +03:00
override fun toString(): String {
return if (this.feature == null) {
"#${this.numberInAlbum}: ${this.trackName} (${this.duration})"
} else {
"#${this.numberInAlbum}: ${this.trackName} ft. ${this.feature} (${this.duration})"
}
}
2023-06-08 13:47:22 +03:00
}