package dk.itu.oop.lecture1; public class Ball { protected int x,y; protected String color; public Ball(String color){ this.color = color; x=0; y=0; } public void move(int dx, int dy){ x+=dx; y+=dy; } public String toString(){ return color + " ball at (" + x + "," + y + ")"; } public boolean equals(Object obj){ if (obj == null) // 1 return false; if (obj == this) // 2 return true; if ( !(obj instanceof Ball) ) // 3 return false; //if ( !super.equals(obj) ) // 4 // return false; Ball other = (Ball)obj; return // 5 this.x == other.x && this.y == other.y; } }