title: Scala: Extend concrete class with constructor parameters
body: <p>I have this concrete class:</p>
  
  <pre><code>class Person (var name: String, var surname: String)
  </code></pre>
  
  <p>and I want to create another class that extends Person:</p>
  
  <pre><code>class Son (name: String, surname: String) extends Person(name, surname)
  </code></pre>
  
  <p>OK.
  But I do want the fields in the constructor of Son must be var and not val.
  How do I fix this? The fields must remain constructor parameters.</p>
  
  <p><strong>UPDATE #2</strong></p>
  
  <p>My problem is as follows:
  If I define a method in Son, this does not work if I change the value to the parameters of an instance of Son.</p>
  
  <pre><code>class Son (name: String, surname: String) extends Person(name, surname){
    def printSon = {
    if(this.name=="name")println("Error name Person")
    if(this.surname=="surname")println("Error surname Person")
    }
  }
  
  object main {
    def main(args: Array[String]): Unit = {}
  
    val Marco = new Son("Marco","Bianchi")
    Marco.printSon // So far everything is ok
    Marco.name="name"
    Marco.printSon // Here in control is not done, because Marco.name="name" writes in Person
    println("FINE")
  }
  </code></pre>
  
  <p>name e surname in Son are of type val.</p>