Commit 83b250af authored by sam.pople's avatar sam.pople

Final finish

parent d0b44f50
......@@ -8,57 +8,49 @@ public class Complex {
real = 0;
imag = 0;
}
public Complex(double r, double i)
{
real = r;
imag = i;
}
public double imag()
{
return imag;
}
public double real()
{
return real;
}
public double magnitude()
{
return Math.sqrt(this.real() * this.real() + this.imag() * this.imag());
return Math.sqrt(Math.pow(real, 2) + Math.pow(imag, 2));
}
public double argument()
{
return Math.atan2(this.imag(),this.real());
return Math.atan2(imag, real);
}
public String toString()
{
String str = "";
if (this.real() != 0) {
str = str + this.real();
if (this.imag > 0) {
str = str + " + ";
}
if (this.imag < 0) {
str = str + " - ";
}
if (this.imag > 0) {
str = str + " + ";
}
}
if (this.imag != 0) {
str = str + "j" + Math.abs(this.imag());
}
return str;
}
public Complex add(Complex complex)
public Complex add(Complex complexNum)
{
Complex answervalue = new Complex(this.real() + complex.real(),this.imag() + complex.imag());
return answervalue;
Complex value = new Complex(this.real() + complexNum.real(),this.imag() + complexNum.imag());
return value;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment