Commit 78df5c8a authored by austin.blanke's avatar austin.blanke

Completed

parent de95c2bd
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -29,23 +29,37 @@ public class Complex { ...@@ -29,23 +29,37 @@ public class Complex {
public double magnitude() public double magnitude()
{ {
return 1.0; return Math.sqrt((real * real) + ((imag * imag)));
} }
public double argument() public double argument()
{ {
return 1.0; return Math.atan2(imag,real);
} }
public String toString() public String toString()
{ {
return ""; if (imag == 0){return String.valueOf(real);}
else if (imag == 0 && real == 0) {return String.valueOf(0);}
else if(real == 0.0){
if(imag < 0){
return "-j" + String.valueOf(-1 * imag);
}
else{
return "j" + String.valueOf(imag);
}
}
else if(imag < 0){return String.valueOf(real) + " - j" + String.valueOf((-1) * imag);}
else {return String.valueOf(real) + " + j" + String.valueOf(imag);}
} }
public Complex add(Complex complexNum) public Complex add(Complex complexNum)
{ {
Complex answer = new Complex(0.0,0.0); Complex answer = new Complex(0.0,0.0);
answer.real = complexNum.real + real;
answer.imag = complexNum.imag + imag;
return answer; return answer;
} }
......
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