Here's a piece of code from my complex numbers class:
public class complex {
private double re;
private double im;
public complex(double real, double imag) {
re = real;
im = imag;
}
public Boolean equals(complex b) {
complex a = this;
return a.re==b.re && a.im==b.im;
}
public Boolean equals(double alpha){
complex a = this;
return a.re==alpha && a.im==0;
}
...
}
And here's what I'm trying to use it for:
public class cubic_cardano {
public static void solveCubic(complex a, complex b, complex c, complex d){
if (a==b && b==c && c==d && d==0) {
...
}
}
...
}
Comparing a complex number to a complex number works just fine while comparing a complex number to a double gives an error:
Incompatible operand types complex and int
What could be the reason and how can I make it work?