Last active
May 23, 2024 13:36
-
-
Save 726f737479/4220a55a16de0171b279e362c6227e83 to your computer and use it in GitHub Desktop.
Kotlin
This file contains 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 drawRating(vote: Int): String { | |
if (vote >= 0 && vote <= 20) { | |
return "★☆☆☆☆" | |
} | |
else if (vote > 20 && vote <= 40) { | |
return "★★☆☆☆" | |
} | |
else if (vote > 40 && vote <= 60) { | |
return "★★★☆☆" | |
} | |
else if (vote > 60 && vote <= 80) { | |
return "★★★★☆" | |
} | |
else if (vote > 80 && vote <= 100) { | |
return "★★★★★" | |
} | |
else { | |
return "☆☆☆☆☆" | |
} | |
} | |
println(drawRating(0) ); // ★☆☆☆☆ | |
println(drawRating(1) ); // ★☆☆☆☆ | |
println(drawRating(50)); // ★★★☆☆ | |
println(drawRating(99)); // ★★★★★ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment