/* * SWE619 * ASSIGNMENT 10 * NAN LI * Point3 * */ package assignment10; import java.util.HashMap; import java.util.Map; public class Point3 extends Point2{ //the z coordinate private int z; //the constructor public Point3(int x, int y, int z){ super(x,y); this.z = z; } //Effects: return true if a object p is equal to this //else return false public boolean equals(Object p){ System.out.println("object3 equals"); if(p instanceof Point3) return equals((Point3) p); return super.equals(p); } //Effects: return true if a Point2 p is equal to this //else return false public boolean equals(Point2 p){ System.out.println("Point2-3 equals"); if(p instanceof Point3) return equals((Point3) p); return super.equals(p); } //Effects: return true if a Point3 p is equal to this //else return false public boolean equals(Point3 p){ System.out.println("Point3 equals"); if(p == null || z != p.z) return false; return super.equals(p); } //Effects: return a hash code for this public int hashCode(){ int result = super.hashCode(); result = 31 * result + z; return result; } }