コード例 #1
0
 public ComplexNumber divide(ComplexNumber other) {
   double tempNumber = other.getA() * other.getA() + other.getB() * other.getB();
   ComplexNumber tempComplexNum = new ComplexNumber(other.getA(), -other.getB());
   tempComplexNum = multiply(tempComplexNum);
   return specialDivide(tempComplexNum, tempNumber);
 }
コード例 #2
0
 public ComplexNumber multiply(ComplexNumber other) {
   double aNew = other.getA() * a - other.getB() * b;
   double bNew = other.getB() * a + other.getA() * b;
   ComplexNumber newComplexNum = new ComplexNumber(aNew, bNew);
   return newComplexNum;
 }
コード例 #3
0
 public ComplexNumber subtract(ComplexNumber other) {
   ComplexNumber newComplexNum = new ComplexNumber(-other.getA(), -other.getB());
   newComplexNum = add(newComplexNum);
   return newComplexNum;
 }
コード例 #4
0
 public ComplexNumber specialDivide(ComplexNumber a, double b) {
   double aNew = a.getA() / b;
   double bNew = a.getB() / b;
   ComplexNumber newComplexNum = new ComplexNumber(aNew, bNew);
   return newComplexNum;
 }
コード例 #5
0
 public ComplexNumber add(ComplexNumber other) {
   double aNew = other.getA() + a;
   double bNew = other.getB() + b;
   ComplexNumber newComplexNum = new ComplexNumber(aNew, bNew);
   return newComplexNum;
 }