NTU-OOP-Tuts-2024/T5Q3/src/Polygon.java

42 lines
907 B
Java
Raw Normal View History

2024-10-16 08:25:34 +08:00
public abstract class Polygon {
//public class Polygon {
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;
}
// public float calArea() {
// return 0;
// }
public void printWidthHeight( ) {
System.out.println("Width = " + width + " Height = " + height);
}
public abstract float calArea();
}