title: Scala function to change attribute of class
body: <p>I created a class Door and want to write a function that changes the open status to whatever is the argument. </p>
  
  <p>The below does not work. What would be the best way of doing that? (Sorry for the beginner question.)</p>
  
  <pre><code>class Door(var name: String,
            var open: Boolean){
          def open_door(newDoorState: Boolean): Unit = new Door(name, newDoorState)
          override def toString(): String =
  "(" + name + ", " + newDoorState + ")"
  
  }
  
  var door = new Door("MyDoor",true)
  door.name // "MyDoor"
  door.open // true
  
  door.open_door(false)
  door.name // "MyDoor"
  door.open // still true. I would like this to be false
  </code></pre>