Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 real;
- }
- public double getImaginary() {
- return imaginary;
- }
- public void add(double real, double imaginary){
- this.real += real;
- this.imaginary += imaginary;
- }
- public void subtract(double real, double imaginary){
- this.real -= real;
- this.imaginary -= imaginary;
- }
- public void add(ComplexNumber otherComplex){
- add(otherComplex.getReal(), otherComplex.getImaginary());
- }
- public void subtract(ComplexNumber otherComplex){
- subtract(otherComplex.getReal(), otherComplex.getImaginary());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement