20145324 Java实验二

实验1:
先建立.java 在建立test

测试正常情况

测试出错情况
错误

修改后的代码

正确

测试边界情况

100时出错
修改后的代码

测试

实验2:
先建test在写,java

实验3:建模

练习
、、、
public class Complex {
public double m_dRealPart;
public double m_dImaginPart;

public Complex(){
    this.m_dImaginPart=0;
    this.m_dRealPart=0;

}
public Complex(double r,double I){
    this.m_dRealPart=r;
    this.m_dImaginPart=I;
}
public double GetRealPart(){return  this.m_dRealPart;}
public double GetImaginaryPart(){return this.m_dImaginPart;}
public void SetRealPart(double d){this.m_dRealPart=d;}
public void SetImaginaryPart(double d){this.m_dImaginPart=d;}

public Complex ComplexAdd1(Complex c){
    this.m_dRealPart=this.m_dRealPart+c.m_dRealPart;
    this.m_dImaginPart=this.m_dImaginPart+c.m_dImaginPart;
    return this;
}
public Complex ComplexAdd2(double c){
    this.m_dRealPart=this.m_dRealPart+c;
    return this;
}

public Complex ComplexMinus1(Complex c){
    this.m_dRealPart=this.m_dRealPart -c.m_dRealPart;
    this.m_dImaginPart=this.m_dImaginPart -c.m_dImaginPart;
    return this;
}
public Complex ComplexMinus2(double c){
    this.m_dRealPart=this.m_dRealPart-c;
    return this;
}
public Complex ComplexMulti1(Complex c){
    double a=this.m_dImaginPart;
    double b=this.m_dRealPart;

    this.m_dRealPart=b*c.m_dRealPart-(a*c.m_dImaginPart);
    this.m_dImaginPart=b*c.m_dImaginPart+a*c.m_dRealPart;
    return this;
}
public Complex ComplexMulti2(double c){
    double a=this.m_dImaginPart;
    double b=this.m_dRealPart;

    this.m_dRealPart=this.m_dRealPart*c;
    this.m_dImaginPart=this.m_dImaginPart*c;
    return this;
}
public String toString(){
    return this.m_dRealPart+"+"+this.m_dImaginPart+"i";
}

}
、、、
测试

步骤 耗时 百分比

需求分析 10m 17%
设计 20m 33%
代码实现 10m 17%
测试 5m 8.3%
分析总结 15m 25%

建模

posted on 2016-04-13 22:02  20145324王嘉澜  阅读(134)  评论(2编辑  收藏  举报