Java Reference
In-Depth Information
GeometricObject
Abstract class name is italicized
-color: String
-filled: boolean
-dateCreated: java.util.Date
#GeometricObject()
#GeometricObject(color: string,
filled: boolean)
+getColor(): String
+setColor(color: String): void
+isFilled(): boolean
+setFilled(filled: boolean): void
+getDateCreated(): java.util.Date
+toString(): String
The # sign indicates
protected modifier
+
getArea()
:
double
+
getPerimeter()
:
double
Abstract methods
are italicized
Methods
getArea
and
getPerimeter
are
overridden in
Circle
and
Rectangle
.
Superclass methods are generally omitted
in the UML diagram for subclasses.
Circle
Rectangle
-radius: double
-width: double
-height: double
+Rectangle()
+Rectangle(width: double, height: double)
+Rectangle(width: double, height: double,
color: string, filled: boolean)
+getWidth(): double
+setWidth(width: double): void
+getHeight(): double
+setHeight(height: double): void
+Circle()
+Circle(radius: double)
+Circle(radius: double, color: string,
filled: boolean)
+getRadius(): double
+setRadius(radius: double): void
+getDiameter(): double
F
IGURE
15.1
The new
GeometricObject
class contains abstract methods.
21 }
22
23
/** Set a new color */
24
public void
setColor(String color) {
25
this
.color = color;
26 }
27
28
/** Return filled. Since filled is boolean,
29
* the get method is named isFilled */
30
public boolean
isFilled() {
31
return
filled;
32 }
33
34
/** Set a new filled */
35
public void
setFilled(
boolean
filled) {
36
this
.filled = filled;
37 }
38
39
/** Get dateCreated */
40
public
java.util.Date getDateCreated() {