Skip to content

Instantly share code, notes, and snippets.

@alexaleluia12
Created October 19, 2023 13:40
Show Gist options
  • Save alexaleluia12/a2b2bc9e8a26dad7c4e9eab15ab5871e to your computer and use it in GitHub Desktop.
Save alexaleluia12/a2b2bc9e8a26dad7c4e9eab15ab5871e to your computer and use it in GitHub Desktop.
Google PlayGround
fun main() {
val s1 = Song("Viva la vida", "One peace", 2010, 90)
val s2 = Song("Nego Drama", "Racionais", 2002, 5000)
println("s1 " + s1.isPopular)
println("s2 "+ s2.isPopular)
println()
s1.printDescription()
s2.printDescription()
}
class Song(val title: String, val artist: String, val yearPublished: Int, var playCount: Int) {
var isPopular: Boolean = popularSound()
get() = popularSound()
fun printDescription() {
println("$title, performed by $artist, was released in $yearPublished.")
}
// reusar esse funcao na checagem
private fun popularSound() = playCount >= 1000
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment