2024-10-22 10:15:20 +08:00
|
|
|
//public abstract class Polygon {
|
|
|
|
public class Polygon {
|
2024-10-16 08:25:34 +08:00
|
|
|
public enum KindofPolygon {
|
|
|
|
POLY_PLAIN,
|
|
|
|
POLY_RECT,
|
|
|
|
POLY_TRIANG
|
|
|
|
};
|
|
|
|
protected String name;
|
|
|
|
protected float width;
|
|
|
|
protected float height;
|
|
|
|
protected KindofPolygon polytype;
|
|
|
|
|
|
|
|
public Polygon(String theName, float theWidth, float theHeight) {
|
|
|
|
name = theName;
|
|
|
|
width = theWidth;
|
|
|
|
height = theHeight;
|
|
|
|
polytype = KindofPolygon.POLY_PLAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
public KindofPolygon getPolytype() {
|
|
|
|
return polytype;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPolytype(KindofPolygon value) {
|
|
|
|
polytype = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2024-10-22 10:15:20 +08:00
|
|
|
public float calArea() {
|
|
|
|
return 0;
|
|
|
|
}
|
2024-10-16 08:25:34 +08:00
|
|
|
|
|
|
|
public void printWidthHeight( ) {
|
|
|
|
System.out.println("Width = " + width + " Height = " + height);
|
|
|
|
}
|
|
|
|
|
2024-10-22 10:15:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public abstract float calArea();
|
2024-10-16 08:25:34 +08:00
|
|
|
|
|
|
|
}
|