Commit e8318647 authored by quinn.haigh's avatar quinn.haigh

final

parent 3608fa81
public class Complex public class Complex
{ {
// set values for numbers
double real; double real;
double imag; double imag;
...@@ -12,6 +12,7 @@ public class Complex ...@@ -12,6 +12,7 @@ public class Complex
imag = 0; imag = 0;
} }
//initiate numbers
public Complex(double _real, double _imag) public Complex(double _real, double _imag)
{ {
...@@ -20,6 +21,7 @@ public class Complex ...@@ -20,6 +21,7 @@ public class Complex
} }
//return values
public double real() public double real()
{ {
...@@ -32,7 +34,9 @@ public class Complex ...@@ -32,7 +34,9 @@ public class Complex
return imag; return imag;
} }
//method to work out magnitude of the numbers
public double magnitude() public double magnitude()
{ {
double answerA = Math.pow(real, 2); double answerA = Math.pow(real, 2);
...@@ -46,7 +50,7 @@ public class Complex ...@@ -46,7 +50,7 @@ public class Complex
} }
//method for returning the arguement
public double argument() public double argument()
{ {
...@@ -55,7 +59,7 @@ public class Complex ...@@ -55,7 +59,7 @@ public class Complex
return arg; return arg;
} }
//method to add complex numbers together
public Complex add(Complex b) public Complex add(Complex b)
{ {
Complex a = this; Complex a = this;
...@@ -67,6 +71,7 @@ public class Complex ...@@ -67,6 +71,7 @@ public class Complex
} }
//printing complex numbers to a string output
public String toString() public String toString()
{ {
if(real == 0.0) if(real == 0.0)
......
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