码迷,mamicode.com
首页 > 其他好文 > 详细

计算机

时间:2016-05-18 14:39:08      阅读:171      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!