/** * 复数的乘法运算。 * c = a * b的运算法则是: * c.实部 = a.实部 * b.实部 - a.虚部 * b.虚部; * c.虚部 = a.虚部 * b.实部 + a.实部 * b.虚部; * @param aComNum 乘数 * @return */ public ComplexNumber multiply(ComplexNumber aComNum) { if (aComNum == null) { System.err.println("对象不能够为null!"); return new ComplexNumber(); } double newReal = this.realPart * aComNum.realPart - this.imaginaryPart * aComNum.imaginaryPart; double newImaginary = this.realPart * aComNum.imaginaryPart + this.imaginaryPart * aComNum.realPart; ComplexNumber result = new ComplexNumber(newReal, newImaginary); return result; }