feat:ChatGPT第 2 课:Scala 函数与方法。

This commit is contained in:
2026-09-15 11:33:58 +08:00
parent e2ad72ecb1
commit d2250abaae
@@ -1,4 +1,5 @@
package practise2.comprehensive
/*
练习 6:综合题 ⭐
@@ -19,15 +20,14 @@ age 是 Int
score 是 Int
函数返回 String
评价部分使用 if
不要在函数里面直接 println
*/
不要在函数里面直接 println*/
object Comprehensive {
def main(args: Array[String]): Unit = {
val result = describeStudent("Tom", 22, 85)
println(result)
}
def describeStudent(name: String, age: Int, score: Int): String ={
def describeStudent(name: String, age: Int, score: Int): String = {
val evaluate = if (score >= 90) {
"优秀"
} else if (score >= 80) {