-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathComplexNumber.java
More file actions
37 lines (30 loc) · 907 Bytes
/
ComplexNumber.java
File metadata and controls
37 lines (30 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public class ComplexNumber {
private double real;
private double imaginary;
public ComplexNumber(double real, double imaginary) {
this.real = real;
this.imaginary = imaginary;
}
public double getReal() {
return this.real;
}
public double getImaginary() {
return this.imaginary;
}
public void add(double real, double imaginery) {
this.real += real;
this.imaginary += imaginary;
}
public void add(ComplexNumber complexNumber) {
this.real += complexNumber.real;
this.imaginary += complexNumber.imaginary;
}
public void subtract(double real, double imaginery) {
this.real -= real;
this.imaginary -= imaginary;
}
public void subtract(ComplexNumber complexNumber) {
this.real -= complexNumber.real;
this.imaginary -= complexNumber.imaginary;
}
}