Compare commits

..
2 Commits
6 changed files with 27 additions and 26 deletions
@@ -1,5 +1,6 @@
package practise1.comprehensive
object Comprehensive {
def main(args: Array[String]): Unit = {
/*第 1 课综合题
@@ -19,7 +20,7 @@ object Comprehensive {
val score = 85
val evaluate =
if (score >= 90 ) "优秀"
if (score >= 90) "优秀"
else if (score >= 80) "良好"
else if (score >= 60) "及格"
else "不及格"
@@ -1,5 +1,6 @@
package practise1.demo
object Demo1VarAndVal {
def main(args: Array[String]): Unit = {
@@ -15,7 +16,6 @@ object Demo1VarAndVal {
println("=================================")
println("=================================")
}
@@ -1,5 +1,6 @@
package practise1.demo
object Demo2Type {
def main(args: Array[String]): Unit = {
//2. 类型
+4 -5
View File
@@ -1,23 +1,22 @@
package practise1.demo
object Demo4If {
def main(args: Array[String]): Unit = {
// Scala 的 if 和 Java 类似
val age = 20
if(age >=18){
if (age >= 18) {
println("成年人")
}else{
} else {
println("未成年")
}
// 但是 Scala 有一个非常重要的特点:if 本身就是一个表达式,可以返回值
val result = if(age >= 18){
val result = if (age >= 18) {
"成年人"
}else{
} else {
"未成年人"
}
@@ -2,7 +2,7 @@ package practise1.exercises
object Exercises1 {
def main(args: Array[String]): Unit = {
/* 练习 1:基本变量
/* 练习 1:基本变量
创建三个变量:
name = "Tom"
@@ -16,6 +16,7 @@ object Exercises1 {
val age = 20
val salary = 15000.5
println(s"${name}今年${age}岁,工资是${salary}")
}
}
@@ -1,5 +1,4 @@
package practise1.exercises
import scala.util.Random
object Exercises4 {