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

ok

parent c094b452
No preview for this file type
public class Complex
{
public double real;
public double imag;
public Complex()
{
real = 0;
imag = 0;
}
public Complex(double r, double i)
{
real = r;
imag = i;
double d = Math.atan2(i,r);
}
public double imag()
{
return imag;
}
public double real()
{
return real;
}
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