导航:网站首页 >
编程定义一个图形接口 Shape, 内含2个抽象方法 get... JAVA编程题:编一个程序包含一个接口 shape(该接...
编程定义一个图形接口 Shape, 内含2个抽象方法 get... JAVA编程题:编一个程序包含一个接口 shape(该接...
相关问题:
匿名网友:
楼主你好
具体代码如下:
/*Shap 接口*/
public interface Shap {
public int getArea();
public String toString();
}
/*Rectangle 抽象类*/
public abstract class Rectangle implements Shap{
public int width,length;
public Rectangle(int w,int l)
{
width = w;
length = l;
}
public Rectangle(){}
public int getArea()
{
return width*length;
}
public String toString()
{
return "长为:"+length+"\t宽为:"+width;
}
public abstract int getGirth();
}
/*Square具体类*/