本帖最后由 张向辉 于 2013-1-16 12:21 编辑
/*定义借口1*/
interface superinterface1
{
static final double PI=3.14;
public double Area();
}
/*定义借口2*/
interface superinterface2
{
double bulk();
}
/*定义一个主程序类实现接口*/
public class interfacetest implements superinterface1,superinterface2
{
double r;
double l;
public interfacetest()
{
this.r=0.0;
this.l=0.0;
}
public interfacetest(double r,double l)
{
this.r=r;
this.l=l;
}
public double Area()
{
return 2*PI*(r+1);
}
public double bulk()
{
return PI*r*r*l;
}
public static void main(String[] args)
{
interface cl=new interface(10.0,6.0);
double arearesult;
arearesult=cl.area();
double bulkresult;
bulkresult=cl.bulk();
System.out.println("面积为"+arearesult);
System.out.println("体积为"+bulkresult);
}
} |