标题:java初学,谁给看一下为什么不对啊,另外此类该如何使用Junit测试
取消只看楼主
伤城11
Rank: 1
等 级:新手上路
帖 子:6
专家分:5
注 册:2013-3-18
结帖率:0
已结贴  问题点数:5 回复次数:0 
java初学,谁给看一下为什么不对啊,另外此类该如何使用Junit测试
package com.li.test;

class Math
{
    private int no1;
    private int no2;
    private int no3=0;
    public void Sum()
    {
        no3=this.getNo1()+this.getNo2();
        System.out.println("Sum "+this.getNo1()+" + "+this.getNo2()+" = "+no3);
    }
    public void Sub()
    {
        no3=this.getNo1()-this.getNo2();
        System.out.println("Sub "+this.getNo1()+" + "+this.getNo2()+" = "+no3);
    }
    public void Mul()
    {
        no3=this.getNo1()*this.getNo2();
        System.out.println("Mul "+this.getNo1()+" + "+this.getNo2()+" = "+no3);
    }
    public void Div()
    {
        if (this.getNo2()!=0)
        no3=this.getNo1()/this.getNo2();
        System.out.println("Div "+this.getNo1()+" + "+this.getNo2()+" = "+no3);
    }
    public void setNo1(int a)
    {
        no1=a;
    }
    public void setNo2(int b)
    {
        no2=b;
    }
    public int getNo1()
    {
        return no1;
    }
    public int getNo2()
    {
        return no2;
    }
}
public class Add {
    public void main(String args[]){
    //    int a=0,b=0;
    //    System.in(a,b);
        Math math=new Math();
        math.setNo1(10);
        math.setNo2(5);
        math.Sum();
        math.Sub();
        math.Mul();
        math.Div();
    }
}
搜索更多相关主题的帖子: void java private package public 
2013-05-17 13:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-407325-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.825248 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved