| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
共有 516 人关注过本帖
标题: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
快速回复:java初学,谁给看一下为什么不对啊,另外此类该如何使用Junit测试
数据加载中...
 
   



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

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