Commit ee33845b authored by cosmina.dunca's avatar cosmina.dunca

finished

parent f2a76a88
No preview for this file type
No preview for this file type
No preview for this file type
public class App {
public static void main(String[] args) throws Exception {
Complex a = new Complex(4.2, 5.7);
// First test
/* Complex a = new Complex(4.2, 5.7);
a.imag();
a.real();
System.out.println(a.imag);
System.out.println(a.real);
System.out.println(a.real());
System.out.println(a.imag()); -> correct */
// Second test
/* Complex a = new Complex(9.6, 11.5);
System.out.println(a.magnitude()); -> correct */
// Third test
/* Complex a = new Complex(9.6, 11.5);
System.out.println(a.argument()); -> correct */
// Fourth test
/* Complex a = new Complex(1.2, 3.4);
System.out.println(a.toString());
Complex b = new Complex(1.2, 0.0);
System.out.println(b.toString());
Complex c = new Complex(0.0, 9.3);
System.out.println(c.toString());
Complex d = new Complex(1.2, -3.4);
System.out.println(d.toString()); -> correct */
// Fifth test
Complex a = new Complex(6.6, 12.9);
Complex b = new Complex(13.1, 13.5);
Complex c = a.add(b);
System.out.println(c.real());
System.out.println(c.imag());
}
}
No preview for this file type
......@@ -2,6 +2,7 @@ public class Complex {
public double real;
public double imag;
public double d;
public Complex()
{
......@@ -13,7 +14,7 @@ public class Complex {
{
this.real = r;
this.imag = i;
//double d = Math.atan2(i,r);
this.d = Math.atan2(i,r);
}
public double imag()
......@@ -33,7 +34,7 @@ public class Complex {
public double argument()
{
return Math.atan2(this.imag, this.real);
return d;
}
public String toString()
......
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