package com.bjsxt.scala trait IsEQU{ def isEqu(o:Any):Boolean def isNotEqu(o:Any) :Boolean = !isEqu(o) } class Point(xx:Int, xy:Int) extends IsEQU { val x = xx val y = xy def isEqu(o: Any): Boolean = { o.isInstanceOf[Point]&&o.asInstanceOf[Point].x == this.x } } object Lesson_Trait2 { def main(args: Array[String]): Unit = { val point1 = new Point(1,2) val point2 = new Point(1,3) println(point1.isNotEqu(point2)) } }