You are to create a class with so-called boundarycells


You are to create a class with so-called BoundaryCells. Methods in the class throw exceptions under certain conditions.

A BoundaryCell object stores an array of double. The constructor has two logical arguments used in the rest of this discussion

- bsize - the number of boundary cells
- vsize - the number of value cells
The total size of an internal array stored in a BoundaryCells object is: 2 * bsize + vsize One can visualize the internal array as three arrays put together into a single array.
[ --- bsize --- ][ ---- vsize ---- ][ --- bsize ---]
The first bsize indices are boundary cells. The last bsize indices are also boundary cells. Example: If you create a BoundaryCells object with bsize=3 and vsize=10, then
- valid indices for Boundary cells are: 0,1,2 and 13,14,15
- valid indices for Value cells are: 3,4,5, 12
Define the following constructor and methods (all should be public)
- BoundaryCells(int vsize, int bsize) throws IllegalArgumentException
o create a BoundaryCells object with an internal double array of size: 2 * bsize + vsize
o throws IllegalArgumentException if either bsize < 0 or vsize < 0
- double setBoundaryCell(int index, double value) throws ArraylndexOutOfBoundsException
o set the contents of the internal array to value if index is a valid index in the "boundary" part of the array
o throws ArraylndexOutOfBounds Exception if index would not store into one of the boundary cells
o return the value set when given a valid

- double setValueCell(int index, double value) throws ArraylndexOutOfBoundsException
o set the contents of the internal array to value if index is a valid index in the "values" part of the array
o throws ArraylndexOutOfBounds Exception if index would not store into one of the boundary cells
o return the value set when given a valid index
- double [] getArray()
o return a reference to the internal array storing the values. This should be a single array and must be a reference (not a deep copy) of the array used to store values.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: You are to create a class with so-called boundarycells
Reference No:- TGS02384751

Now Priced at $20 (50% Discount)

Recommended (99%)

Rated (4.3/5)