Commit c97f3029 authored by a-j.towse's avatar a-j.towse

toString WIP

parent bf380f35
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -29,17 +29,28 @@ public class Complex {
public double magnitude()
{
return 1.0;
return (Math.sqrt(Math.pow(real, 2)+Math.pow(imag, 2)));
}
public double argument()
{
return 1.0;
return Math.atan2(imag, real);
}
public String toString()
public String toString() //Current W.I.P
{
return "";
String StringReal = "";
if (real != 0){ StringReal = Double.toString(real);}
if (imag > 0){
return StringReal + " + " + 'j' + Double.toString(imag);
}
else if (imag < 0){
return StringReal + " - " + 'j' + Double.toString(imag + Math.abs(-1));
}
else{
return StringReal;
}
}
public Complex add(Complex complexNum)
......
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