scala样例类案例Calculate
作者:互联网
object Calculate {
case class Calculate(a: Int, b: Int) {
def add(): Int = a + b
def subtract(): Int = a - b
def multiply(): Int = a * b
def divide(): Int = a / b
}
def main(args: Array[String]): Unit = {
val c = Calculate(7, 5)
println("加法:" + c.add())
println("减法:" + c.subtract())
println("乘法:" + c.multiply())
println("除法:" + c.divide())
}
}
标签:Calculate,scala,Int,样例,add,println,def,divide 来源: https://blog.csdn.net/m0_58535137/article/details/123027031