Created
October 19, 2023 13:40
-
-
Save alexaleluia12/a2b2bc9e8a26dad7c4e9eab15ab5871e to your computer and use it in GitHub Desktop.
Google PlayGround
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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