/**
 * A rectangular array of objects
 *
 */
    public class RectangularArrayV2
   {
      private int       columns, rows;
      private Object[]  data;
    
   
    /**
     * Explicit Value Constructor
     *
     * @param rows    The number of rows
     * @param columbs The number of columns
     */
       public RectangularArrayV2(int rows, int columns)
      {
         this.columns = columns;
         this.rows    = rows;
         data = new Object [rows * columns];
      }// end RectangularArray constructor
   
   
    /**
     * Returns the number of columns in this RectangularArray
     *
     * @return   The number of columns
     */
       public int columns()
      {
         return columns;  
      } // end columns
    
    /**
     * Get the element at a particular row and column
     *
     * @param row     The row index
     * @param column  The column index
     * @return        The Object at the given row and column
     */
       public Object getElementAt(int row, int column)
       							throws IndexOutOfBoundsException
      {
         Object myObject;
         int i;
         i = index(row, column);
         myObject = data[i];
         return myObject;
      }// end getElementAt
    
    /**
     * This implementation uses an ordinary array as the underlying
     * data structure.  This converts from VALID row and column indexes
     * to an index into the underlying data structure.
     *
     * @param row     The row index
     * @param column  The column index
     * @return        The corresponding index in the data array
     */
       private int index(int row, int column) 
                   //  throws IndexOutOfBoundsException
      {
         int i;
         i = row*columns + column;         
         if (row > rows || column > columns || i > data.length)
            throw new IndexOutOfBoundsException 
               (" row: " + row + " column: " + column); // parameter is message
         else
            return i;
      }// end index
    
   
    /**
     * Returns the number of rows in this RectangularArray
     *
     * @return   The number of rows
     */
       public int rows()
      {
         return rows;
      } // end rows
    
   
    /**
     * Set the element at a particular row and column
     *
     * @param row     The row index
     * @param column  The column index
     * @param anObject The Object to put in the array
     */
       public void setElementAt(int row, int column, Object anObject)
       							 throws IndexOutOfBoundsException
      {
         int location;
         location = index(row,column);
         data[location] = anObject;
      } // end setElementAt
   }// end class
