Commit b7cbf7a2 authored by daniel pearson's avatar daniel pearson

Oriign

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