Java Reference
In-Depth Information
9 }
10
11
/** Construct a geometric object with the specified color
12
* and filled value */
13
public SimpleGeometricObject(String color, boolean filled) {
dateCreated = new java.util.Date();
14
15
this .color = color;
16
this .filled = filled;
17 }
18
19
/** Return color */
20
public String getColor() {
21
return color;
22 }
23
24
/** Set a new color */
25
public void setColor(String color) {
26
this .color = color;
27 }
28
29
/** Return filled. Since filled is boolean,
30
its get method is named isFilled */
31
public boolean isFilled() {
32
return filled;
33 }
34
35
/** Set a new filled */
36
public void setFilled( boolean filled) {
37
this .filled = filled;
38 }
39
40
/** Get dateCreated */
41
public java.util.Date getDateCreated() {
42
return dateCreated;
43 }
44
45
/** Return a string representation of this object */
46
public String toString() {
47
return "created on " + dateCreated + "\ncolor: " + color +
48
" and filled: " + filled;
49 }
50 }
L ISTING 11.2 CircleFromSimpleGeometricObject.java
1 public class CircleFromSimpleGeometricObject
2
extends SimpleGeometricObject
{
extends superclass
data fields
3
private double radius;
4
5 public CircleFromSimpleGeometricObject() {
6 }
7
8
constructor
public CircleFromSimpleGeometricObject( double radius) {
9
this .radius = radius;
10 }
11
12 public CircleFromSimpleGeometricObject( double radius,
13 String color, boolean filled) {
14 this .radius = radius;
15 setColor(color);
 
Search WWH ::




Custom Search