public
static void main(String
[] args
) {
Square s1
= new
Square();
Circle c1
= new
Circle();
System
.out
.println("长方形面积:"+s1
.area(2.0));
System
.out
.println("圆形面积:"+c1
.area(3.0));
}
}
interface Shape
{
abstract
double area(double s
);
}
class Square implements Shape
{
public
double area(double l
){
double area
;
area
= l
*l
;
return area
;
}
}
class Circle implements Shape
{
public
double area(double r
) {
double area
;
area
= Math
.PI
*r
*r
;
return area
;
}
}
转载请注明原文地址: https://lol.8miu.com/read-21657.html