An Introduction to Developing Classes
with Examples in Java |
Prof. David Bernstein
|
Computer Science Department |
bernstdh@jmu.edu |
access class class-name
{
this
can be used to disambiguate between
local variables/formal parameters and attributes with the
same namethis
Revisited.
operator (i.e., the membership operator) so must refer to
an objectnew
operatorA 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.
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.
toString()
that returns a
human-readable String
representation of all
of the (important) attributestoString()
MethodtoString()
methodequals()
method
that returns true
if the attributes are the
samecompareTo()
method of objects
can be orderedequals()
MethodtoString()
methodequals()
methodPictureFrame
Class