Commit 31daeb36 authored by sam.pople's avatar sam.pople

worked again

parent 22a525a6
public class Complex {
public double real;
public double image;
public double imag;
public Complex()
{
real = 0;
image = 0;
imag = 0;
}
public Complex(double r, double i)
{
real = r;
image = i;
imag = i;
}
public double imag()
{
return image;
return imag;
}
public double real()
......@@ -35,30 +36,25 @@ public class Complex {
{
return Math.atan2(this.imag(),this.real());
}
public String toString()
{
String str = "";
if (this.real() != 0) {
str = str + this.real();
if (this.image > 0) {
if (this.imag > 0) {
str = str + " + ";
}
if (this.image < 0) {
if (this.imag < 0) {
str = str + " - ";
}
}
if (this.image != 0) {
if (this.imag != 0) {
str = str + "j" + Math.abs(this.imag());
}
return str;
}
public Complex add(Complex complex)
{
Complex answervalue = new Complex(this.real() + complex.real(),this.imag() + complex.imag());
......
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