Commit fd790f99 authored by jose.alencastro's avatar jose.alencastro

ok

parent c094b452
No preview for this file type
......@@ -30,25 +30,44 @@ public class Complex
public double magnitude()
{
return 1.0;
double magnitude = Math.sqrt(Math.pow(this.real, 2) + Math.pow(this.imag, 2));
return magnitude;
}
public double argument()
{
return 1.0;
return Math.atan2(imag,real);
}
public String toString()
{
return "";
String imagString = Double.toString(imag);
String realString = Double.toString(real);
if (real !=0 )
{
if (imag !=0 )
{
if (imag < 0)
{
String imagString2 = imagString.replace("-","");
return realString+" - "+"j"+imagString2;
}
return realString+" + "+"j"+imagString;
}
else
{
return realString;
}
}
return realString;
}
public Complex add(Complex complexNum)
{
Complex answer = new Complex(0.0,0.0);
answer.real = complexNum.real + real;
answer.imag = complexNum.imag + imag;
return answer;
}
}
\ No newline at end of file
}
\ No newline at end of file
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