Fahad/CodeSamples/Classes.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Wed, 06 Jan 2016 12:24:29 +0000
changeset 87 030939b7d475
parent 44 a751aa1ee4f7
permissions -rw-r--r--
added type inference paper and updated Re.thy

package Main

class Point(xc: Int, yc: Int) {
  var x: Int = xc
  var y: Int = yc
  def move(dx: Int, dy: Int) {
    x = x + dx
    y = y + dy
  }
  override def toString(): String = "(" + x + ", " + y + ")";
}

object Classes{
  def main(args: Array[String]){
    val pt = new Point(1,2)
    println(pt)
    pt.move(10,10)
    println(pt)
  }
}