已定义一个Shape抽象类,在此基础上派生出矩形Rectangle和圆形Circle类

日期:2011-06-30 19:48:08 人气:1

已定义一个Shape抽象类,在此基础上派生出矩形Rectangle和圆形Circle类

abstract class Shape {public Shape(){} public float GetPerim(){return 0;} } class Rectangle extends Shape { private float x=0,y=0; public Rectangle(float x,float y){ this.x=x; this.y=y; } public float GetPerim() { return 2*(x+y); } } class Circle ext
    A+
热门评论