@Test public void testEquals() { Vector v1 = new Vector(1.0, 2.0); Vector v2 = new Vector(1.0, 2.0); assertEquals(v1, v2); assertEquals(v2, v1); v1 = new Vector(1.1, 2.0); assertFalse(v1.equals(v2)); v2 = new Vector(1.1, 2.0); assertEquals(v1, v2); v1 = new Vector(1.1, 2.2); assertFalse(v1.equals(v2)); v2 = new Vector(1.1, 2.2); assertEquals(v1, v2); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Vector)) { return false; } Vector that = (Vector) obj; if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } return true; }
Vector implements Serializable { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Vector)) { return false; } Vector that = (Vector) obj; if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } return true; } }
Vector implements Serializable { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Vector)) { return false; } Vector that = (Vector) obj; if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } return true; } Vector(double x, double y); }
Vector implements Serializable { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Vector)) { return false; } Vector that = (Vector) obj; if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } return true; } Vector(double x, double y); double getX(); double getY(); double getLength(); double getAngle(); @Override boolean equals(Object obj); @Override int hashCode(); }
Vector implements Serializable { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Vector)) { return false; } Vector that = (Vector) obj; if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } return true; } Vector(double x, double y); double getX(); double getY(); double getLength(); double getAngle(); @Override boolean equals(Object obj); @Override int hashCode();  }