Commit 8c436870 authored by sam.pople's avatar sam.pople

initial commit

parent f8ea15b0
No preview for this file type
File added
public class Complex {
public double real;
public double imag;
public double image;
public Complex()
{
real = 0;
imag = 0;
image = 0;
}
public Complex(double r, double i)
{
real = r;
imag = i;
double d = Math.atan2(i,r);
image = i;
}
public double imag()
{
return imag;
return image;
}
public double real()
......@@ -29,24 +28,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 str = "";
if (this.real() != 0) {
str = str + this.real();
if (this.image > 0) {
str = str + " + ";
}
if (this.image < 0) {
str = str + " - ";
}
}
if (this.image != 0) {
str = str + "j" + Math.abs(this.imag());
}
return str;
}
public Complex add(Complex complexNum)
public Complex add(Complex complex)
{
Complex answer = new Complex(0.0,0.0);
Complex answervalue = new Complex(this.real() + complex.real(),this.imag() + complex.imag());
return answer;
return answervalue;
}
......
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