Commit 3ac451ce authored by Volcanex's avatar Volcanex

Finished

parent bf380f35
No preview for this file type
No preview for this file type
No preview for this file type
public class Complex {
public double real;
......@@ -14,7 +16,7 @@ public class Complex {
{
real = r;
imag = i;
double d = Math.atan2(i,r);
}
public double imag()
......@@ -29,22 +31,42 @@ public class Complex {
public double magnitude()
{
return 1.0;
return Math.sqrt(this.real()*this.real() + this.imag()*this.imag());
}
public double argument()
{
return 1.0;
return Math.atan2(this.imag(),this.real());
}
public String toString()
{
return "";
String string = "";
if (this.real() != 0){
string = string+this.real();
if (this.imag > 0) {
string = string+" + ";
}
if (this.imag < 0) {
string = string+" - ";
}
}
if (this.imag != 0) {
string = string + "j"+Math.abs(this.imag());
}
return string;
}
public Complex add(Complex complexNum)
{
Complex answer = new Complex(0.0,0.0);
Complex answer = new Complex(this.real()+complexNum.real(),this.imag()+complexNum.imag());
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