Forked from 726f737479/gist:4220a55a16de0171b279e362c6227e83
Last active
January 28, 2025 14:15
-
-
Save dmsl1805/5557e478a44437e2b103bc9c1851f355 to your computer and use it in GitHub Desktop.
Kotlin
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
package main | |
import "fmt" | |
func 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 "☆☆☆☆☆" | |
} | |
} | |
func main() { | |
fmt.Println(drawRating(0)) // ★☆☆☆☆ | |
fmt.Println(drawRating(1)) // ★☆☆☆☆ | |
fmt.Println(drawRating(50)) // ★★★☆☆ | |
fmt.Println(drawRating(99)) // ★★★★★ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment