|
Developing Classes
With Examples in Java |
|
Prof. David Bernstein
|
| Computer Science Department |
| bernstdh@jmu.edu |
A picture frame is used to display a picture. It always has a width and height (measured in inches). It may or may not have a matte/border (also measured in inches). If it has a matte, it is the same size on all four sides. One can calculate the visible area of a picture frame from its area and the area of the matte.
A picture frame may or may not have a stand.
One can calculate the cost of a picture frame from the amount of material used in the perimeter of the frame itself and the area of the glass.
A picture frame is used to display a picture. It always has a width and height (measured in inches). It may or may not have a matte/border (also measured in inches). If it has a matte, it is the same size on all four sides. One can calculate the visible area of a picture frame from its area and the area of the matte.
A picture frame may or may not have a stand.
One can calculate the cost of a picture frame from the amount of material used in the perimeter of the frame itself and the area of the glass.
equals() and toString() Methods
this() provided the calls are made
in the first statement
clone() method creates a shallow copy
In this example, since both of the attributes are primitive types, the distinction between shallow and deep copies does not arise.
javaexamples/basics/Pair.java (Fragment: CopyConstructor)
If, for example, the Pair class included a String
attribute named id, then a shallow copy would include the
statement:
whereas a deep copy would include the statement:
static
Integer Class:
MIN_VALUE
MAX_VALUE
Double Class:
NEGATIVE_INFINITY
POSITIVE_INFINITY
MIN_VALUE
MAX_VALUE
Math Class:
E (base of the natural log)PI
static
Math Class:
abs
sin
cos
tan
log
pow
sqrt
return statement
parsePictureFrame() Method in the PictureFrame Class
null, to return
a specialization, to return a realization,
to return a remote object)