代码拉取完成,页面将自动刷新
package point4;
public class Complex {
public double getImagePart() {
return ImagePart;
}//取得虚数部分
public double getRealPart() {
return RealPart;
}//取得实数部分
double RealPart;
double ImagePart;
public void setRealPart(double realPart) {
RealPart = realPart;
}
public void setImagePart(double imagePart) {
ImagePart = imagePart;
}
public Complex(){}
public Complex(double R,double I) {
this.ImagePart = I;
this.RealPart = R;
}
public String toString() {
return "Complex{" +
"RealPart=" + RealPart +
", ImagePart=" + ImagePart +
'}';
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Complex complex = (Complex) o;
return Double.compare(complex.getRealPart(), getRealPart()) == 0 &&
Double.compare(complex.getImagePart(), getImagePart()) == 0;
}
Complex ComplexAdd(Complex a) {
return new Complex(this.RealPart + a.RealPart,this.ImagePart + a.ImagePart);
}
Complex ComplexSub(Complex a){
return new Complex(this.RealPart - a.RealPart,this.ImagePart - a.ImagePart);
}
Complex ComplexMulti(Complex a){
return new Complex(this.RealPart*a.RealPart-this.ImagePart*a.ImagePart,
this.ImagePart*a.RealPart+this.RealPart*a.ImagePart);
}
Complex ComplexDiv(Complex a){
double scale = a.getRealPart()*a.getRealPart() + a.getImagePart()*a.getImagePart();
Complex b = new Complex(a.getRealPart() / scale, - a.getImagePart() / scale);
return this.ComplexMulti(b);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。