Java Reference
In-Depth Information
public double
getWidth()
{
return
width;
}
public double
area()
{
return
length * width;
}
public double
perimeter()
{
return
2 * (length + width);
}
public
String toString()
{
return
("Length = "
+ length + "; Width = " + width);
}
}
Figure 10-2 shows the UML class diagram of the
class
Rectangle
.
Rectangle
-length:
double
-width:
double
+Rectangle()
+Rectangle(
double
,
double
)
+setDimension(
double
,
double
):
void
+getLength():
double
+getWidth():
double
+area():
double
+perimeter():
double
+toString():
String
FIGURE 10-2
UML class diagram of the
class
Rectangle
The
class
Rectangle
has
10
members.
Now consider the following definition of the
class
Box
, derived from the
class
Rectangle
:
Search WWH ::
Custom Search