Fahad/CodeSamples/Classes.scala
author Chengsong
Mon, 10 Jul 2023 01:51:46 +0100
changeset 661 71502e4d8691
parent 44 a751aa1ee4f7
permissions -rw-r--r--
overview of finiteness proof Gerog comment "not helpful", adding more intuitions of "closed forms"

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)
  }
}