Java Reference
In-Depth Information
GeometricObject
-color: String
-filled: boolean
-dateCreated: java.util.Date
The color of the object (default: white ).
Indicates whether the object is filled with a color (default: false ).
The date when the object was created.
+GeometricObject()
Creates a GeometricObject .
+GeometricObject(color: String,
filled: boolean)
+getColor(): String
+setColor(color: String): void
+isFilled(): boolean
+setFilled(filled: boolean): void
+getDateCreated(): java.util.Date
+toString(): String
Creates a GeometricObject with the specified color and filled
values.
Returns the color.
Sets a new color.
Returns the filled property.
Sets a new filled property.
Returns the dateCreated .
Returns a string representation of this object.
Circle
Rectangle
-radius: double
-width: double
-height: double
+Circle()
+Circle(radius: double)
+Circle(radius: double, color: String,
filled: boolean)
+getRadius(): double
+Rectangle()
+Rectangle(width: double, height: double)
+Rectangle(width: double, height: double
color: String, filled: boolean)
+getWidth(): double
+setRadius(radius: double): void
+getArea(): double
+setWidth(width: double): void
+getPerimeter(): double
+getDiameter(): double
+getHeight(): double
+setHeight(height: double): void
+printCircle(): void
+getArea(): double
+getPerimeter(): double
F IGURE 11.1
The GeometricObject class is the superclass for Circle and Rectangle .
SimpleGeometricObject , CircleFromSimpleGeometricObject , and
RectangleFromSimpleGeometricObject in this chapter. For simplicity, we will
still refer to them in the text as GeometricObject , Circle , and Rectangle
classes. The best way to avoid naming conflicts is to place these classes in different
packages. However, for simplicity and consistency, all classes in this topic are placed in
the default package.
L ISTING 11.1 SimpleGeometricObject.java
1 public class SimpleGeometricObject {
2
private String color = "white" ;
data fields
3
private boolean filled;
4
private java.util.Date dateCreated;
5
6
/** Construct a default geometric object */
7
public SimpleGeometricObject() {
constructor
date constructed
8
dateCreated = new java.util.Date();
 
Search WWH ::




Custom Search