import java.util.Date;
public abstract class GeometricObject {
private String color = "white";
private boolean filled;
Date dateCreated;
protected GeometricObject() {
dateCreated = new Date();
}
protected GeometricObject(String color, boolean filled) {
this.color = color;
this.filled = filled;
Date dateCreated = new Date();
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public boolean isFilled() {
return filled;
}
public void setFilled(boolean filled) {
this.filled = filled;
}
public Date getDateCreated() {
return dateCreated;
}
public String toString() {
return "Created on " + dateCreated + "\ncolor " + color +
" and filled" + filled;
}
public abstract double getArea();
public abstract double getPerimeter();
}
public abstract class GeometricObject {
private String color = "white";
private boolean filled;
Date dateCreated;
protected GeometricObject() {
dateCreated = new Date();
}
protected GeometricObject(String color, boolean filled) {
this.color = color;
this.filled = filled;
Date dateCreated = new Date();
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public boolean isFilled() {
return filled;
}
public void setFilled(boolean filled) {
this.filled = filled;
}
public Date getDateCreated() {
return dateCreated;
}
public String toString() {
return "Created on " + dateCreated + "\ncolor " + color +
" and filled" + filled;
}
public abstract double getArea();
public abstract double getPerimeter();
}
本文介绍了一个用于表示几何对象的抽象类,包括颜色、填充状态和创建日期的属性,以及获取和设置这些属性的方法。
1万+

被折叠的 条评论
为什么被折叠?



