/**
* 接口Max
* 本类中有两个方法
* @author pisa
*/
public interface Max {
public double twoMax(double a,double b);//两个数中最大
public double threeMax(double a,double b,double c);//三个数中最大
}
/**
* Test类实现了Max接口,并且实现了Max接口中的所有方法。
* @author pisa
*/
public class Test implements Max{
public double threeMax(double a, double b, double c) {
if(c>=twoMax(a,b))
return c;
else
return twoMax(a,b);
}
public double twoMax(double a, double b) {
if(a>=b)
return a;
else
return b;
}
public static void main(String[]args){
Test t = new Test();
System.out.println(t.twoMax(1.2, 5));
System.out.println(t.threeMax(34, 78, -23));
}
}
/**
* Staff该java Bean 有4个职员基本的信息
* 并且提供了设置和得到该职员信息的基本方法
* @author pisa
*/
public class Staff {
private String name; //职员姓名
private Integer age; //职员年龄
private String sex; //职员性别
private String position;//职员职位
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
}
您的进步是我最大的动力和满足,如果您对我的回答很满意,请给我多加分。谢谢!
温馨提示:答案为网友推荐,仅供参考