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));
}
}
![]()