|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectNumbers.ComplexNumber
public class ComplexNumber
Models a complex number, in the form "a + bi".
| Field Summary | |
|---|---|
private double |
imag
imaginary part of the complex number |
private double |
real
real part of the complex number |
| Constructor Summary | |
|---|---|
ComplexNumber(ComplexNumber cn)
Constructs a complex number based on another complex number. |
|
ComplexNumber(double a,
double b)
Constructs a new complex number. |
|
| Method Summary | |
|---|---|
ComplexNumber |
add(ComplexNumber cn1)
Adds 2 complex numbers. |
ComplexNumber |
divide(ComplexNumber cn1)
Divides 2 complex numbers. |
double |
getImag()
Returns the imaginary part of the complex number. |
double |
getReal()
Returns the real part of the complex number. |
ComplexNumber |
multiply(ComplexNumber cn1)
Multiplies 2 complex numbers. |
void |
multiply(double x)
Multiplies a complex number by a regular number. |
void |
setImag(double a)
Sets the imaginary part of the complex number. |
void |
setReal(double a)
Sets the real part of the complex number. |
void |
squareRoot()
Takes the square root of a complex number. |
ComplexNumber |
subtract(ComplexNumber cn1)
Subtracts 2 complex numbers. |
java.lang.String |
toString()
A string which returns the real and imaginary parts of the complex number. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private double real
private double imag
| Constructor Detail |
|---|
public ComplexNumber(double a,
double b)
a - - The real part of the complex number.b - - The imaginary part of the complex number.public ComplexNumber(ComplexNumber cn)
cn - - The other complex number.| Method Detail |
|---|
public void setReal(double a)
a - - value for real part.public double getReal()
public void setImag(double a)
a - - value for imaginary part.public double getImag()
public ComplexNumber multiply(ComplexNumber cn1)
cn1 - - the second complex number.
public ComplexNumber divide(ComplexNumber cn1)
cn1 - - the second complex number.
public ComplexNumber subtract(ComplexNumber cn1)
cn1 - - the second complex number.
public ComplexNumber add(ComplexNumber cn1)
cn1 - - the second complex number.
public void multiply(double x)
x - - regular number by which the complex number will be multiplied.public void squareRoot()
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||