Advertisement
Guest User

Untitled

a guest
Jun 10th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.41 KB | None | 0 0
  1. class Point[T <: Number](val x:T, val y:T) {
  2.  
  3.   def + (other : Point[T]) : Point[T]  = new Point[T] ( x + other.x, y + other.y)
  4.  
  5.   def - (other : Point[T]) : Point[T] = new Point[T] ( this.x - other.x, this.y - other.y)
  6.   def unary_ : Point[T] = new Point[T](-this.x, -this.y)
  7.   def == (other : Point[T]) : Boolean = (this.x == other.x && this.y == other.y)
  8.   def != (other : Point[T]) : Boolean = !(this == other)
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement