首页 > 其他 > 详细

计算机

时间:2016-05-18 14:36:09      阅读:207      评论:0      收藏:0      [点我收藏+]
package com.text;
//计算器
public class JiSuanQi {
    
    private String Type;

    public JiSuanQi(String type) {
        super();
        Type = type;
    }

    public String getType() {
        return Type;
    }

    public void setType(String type) {
        Type = type;
    }
    //加法 计算整数
    public int doAddidtion(int a,int b)
    {
        return a+b;
    }
    //加法 计算浮点数
    //方法的重载
    //1.方法名相同,但参数不同
    //2.跟返回值无关
    //3.这是多态的一种表现
    public double doAddidtion(double a,double b)
    {
        return a+b;
    }
    
    //测试

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        JiSuanQi jsq1=new JiSuanQi("标准型");
                
                System.out.println("123+456="+jsq1.doAddidtion(123, 456));
                
                System.out.println("123.12+456.45="+jsq1.doAddidtion(123.12, 456.45));

    }

}

技术分享

计算机

原文:http://www.cnblogs.com/weiwenxin01/p/5505004.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!