Commit 7bb37aed authored by a-j.towse's avatar a-j.towse

toString completed

parent c97f3029
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -37,19 +37,20 @@ public class Complex {
return Math.atan2(imag, real);
}
public String toString() //Current W.I.P
{
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));
public String toString(){
if (real == 0){
return 'j' + Double.toString(Math.abs(imag));
}
else{
return StringReal;
if (imag > 0){
return Double.toString(real) + " + " + 'j' + Double.toString(imag);
}
else if (imag < 0){
return Double.toString(real) + " - " + 'j' + Double.toString(Math.abs(imag));
}
else{
return Double.toString(real);
}
}
}
......
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