Fahad/CodeSamples/Classes.scala
changeset 44 a751aa1ee4f7
equal deleted inserted replaced
43:10e7a90d8e7a 44:a751aa1ee4f7
       
     1 package Main
       
     2 
       
     3 class Point(xc: Int, yc: Int) {
       
     4   var x: Int = xc
       
     5   var y: Int = yc
       
     6   def move(dx: Int, dy: Int) {
       
     7     x = x + dx
       
     8     y = y + dy
       
     9   }
       
    10   override def toString(): String = "(" + x + ", " + y + ")";
       
    11 }
       
    12 
       
    13 object Classes{
       
    14   def main(args: Array[String]){
       
    15     val pt = new Point(1,2)
       
    16     println(pt)
       
    17     pt.move(10,10)
       
    18     println(pt)
       
    19   }
       
    20 }