Question: b) (15 pts) Add a method to the ComplexTuple class that overrides the equals() method from java.lang, Object to perform a deep comparison between this

b) (15 pts) Add a method to the ComplexTuple class that overrides the equals() method from java.lang, Object to perform a deep comparison between this object and an existing ComplexTuple object. Two Complexes are considered to be equal if they have the same real and imaginary parts. You can assume that complex has a correctly implemented equals() method. @Override public boolean equals(object o) { // TODO Sample code for Problem 2 public class complex implements Cloneable { private int re; // real part private int im; // imaginary part public Complex (int re, intim) { this.re = re; this. im im; } @Override public boolean equals (Object o) { Il assume this is already implemented; the // implementation details irrelevant. 3 } public class complexTuple { private Complex ci; private Complex c2; public ComplexTuple (Complex ci, Complex c2) { this.cl = c1; this.cz c2; 3 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
