object SimpleObjectApp {
  def main(args: Array[String]): Unit = {
    val person = new People
    person.name = "hxs"
    println(person.name + ":" + person.age)
    println("invoke eat method: " + person.eat())
    person.watchFootball("Barcelona")


    person.printInfo()
  }
}

class People {
  // var是变量,自动生成get,set
  // _ 是占位符,使用占位符,必须指明数据类型
  var name: String = _

  // 根据值 10,可以自动判断是整型,可以省略不写数据类型
  val age : Int    = 10

  // 私有
  private [this] val gender = "male"
  def printInfo(): Unit ={
    println("gender: " + gender)
  }

  def eat(): String = {
    name + " eat..."
  }

  def watchFootball(teamName: String): Unit ={
      println(name + " is watching match of " + teamName)
  }


}

占位符 _

// val 是不能重新赋值的,所以报错
scala> val d:Double = _
<console>:11: error: unbound placeholder parameter
       val d:Double = _
                      ^
// Double 默认 0.0
scala> var d:Double = _
d: Double = 0.0

// Int 默认 0
scala> var d:Int = _
d: Int = 0

// String 默认为null
scala> var d:String = _
d: String = null