Instructions: Answer as many of the following questions as you can during the lab period. If you are unable to complete the assignment during the lab period it is strongly recommended that you complete it on your own.
Getting Ready: Before going any further, you should:
In lecture we discussed how to create arrays of arrays in Java, and
how this technique could be used to store a "rectangular array" of
values. In this lab you will create a RectangularArray
class that uses an "ordinary" array as the underlying data structure
(i.e., the realization in computer memory of the values).
Such a data structure (for the same example as above)
can be illustrated as follows:
Here, the first 4 elements correspond to the first row and the second 4 elements correspond to the second row. Obviously, this can be generalized for any n x m rectangular array.
RectangularArray
class.
columns()
and
rows()
methods.
index()
method.
setElementAt()
method.
getElementAt()
method.
Driver
class that creates a 2x4
RectangularArray
, fills it with the String
objects "A", "B", ..., "H" and then prints the elements in table format.
RectangularArray.java
to
RectangularArray.v1
and into the worksheet.
RectangularArray
class type-safe.
Driver
accordingly.
Copyright 2010