feat:ChatGPT第 2 课:Scala 函数与方法。
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
package practise2.comprehensive
|
package practise2.comprehensive
|
||||||
|
|
||||||
/*
|
/*
|
||||||
练习 6:综合题 ⭐
|
练习 6:综合题 ⭐
|
||||||
|
|
||||||
@@ -19,15 +20,14 @@ age 是 Int
|
|||||||
score 是 Int
|
score 是 Int
|
||||||
函数返回 String
|
函数返回 String
|
||||||
评价部分使用 if
|
评价部分使用 if
|
||||||
不要在函数里面直接 println
|
不要在函数里面直接 println*/
|
||||||
*/
|
|
||||||
object Comprehensive {
|
object Comprehensive {
|
||||||
def main(args: Array[String]): Unit = {
|
def main(args: Array[String]): Unit = {
|
||||||
val result = describeStudent("Tom", 22, 85)
|
val result = describeStudent("Tom", 22, 85)
|
||||||
println(result)
|
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) {
|
val evaluate = if (score >= 90) {
|
||||||
"优秀"
|
"优秀"
|
||||||
} else if (score >= 80) {
|
} else if (score >= 80) {
|
||||||
|
|||||||
Reference in New Issue
Block a user