java web编程技术(沈泽刚,清华大学出版社)第十四章课后习题部分解答
Book14_1
public class Book14_1{
public static void main(String[] args) {
}
abstract class GeometricObject{
private String color = "white";
private boolean filled;
private java.util.Date dateCreated; protected GeometricObject() { dateCreated = new java.util.Date(); } protected GeometricObject(String color, boolean filled){ } public String getColor() { return color; dateCreated = new java.util.Date(); this.color = color; this.filled = filled; } GeometricObject geoObject1 = new Circle(5); GeometricObject geoObject2 = new Rectangle(5, 3); System.out.println("The two objects have the same area? " + equalArea(geoObject1, geoObject2)); displayGeometricObject(geoObject1); displayGeometricObject(geoObject2); public static boolean equalArea(GeometricObject object1, GeometricObject object2){ } return object1.getArea() == object2.getArea(); public static void displayGeometricObject(GeometricObject object){ } System.out.println(); System.out.println("The area is " + object.getArea()); System.out.println("The perimeter is " + object.getPerimeter());