Area 类:
public abstract interface Area {
public double area(double a, double b);
}
RectArea 类:
public interface RectArea extends Area{
public double area(double a, double b);
}
RoundArea 类:
public interface RoundArea extends Area{
public double area(double a,double b);
}
ImpleArea :实现类
public class ImpleArea implements Area,RectArea,RoundArea{
public double area(double a, double b) {
double temp =0d;
//圆的面积 a半径 b半径
if(a==b){
temp=3.14*a*b;
}
//长方形的面积
else{
temp=a*b;
}
return temp;
}
}
希望我的答案你能满意~~~