Here is the starter code: /** * Given a 2D array of ints return the value of
Question:
Here is the starter code:
/**
* Given a 2D array of ints return the value of the
* most valuable contiguous sub rectangle in the 2D array.
* The sub rectangle must be at least 1 by 1.
*
pre: mat != null, mat.length > 0, mat[0].length > 0,
* mat is a rectangular matrix.
*
post: return the value of the most valuable contiguous sub rectangle
* in city.
* @param city The 2D array of ints representing the value of
* each block in a portion of a city.
* @return return the value of the most valuable contiguous sub rectangle
* in city.
*/
public static int getValueOfMostValuablePlot(int[][] city) {
// check preconditions
if (city == null || city.length == 0 || city[0].length == 0
|| !isRectangular(city) ) {
throw new IllegalArgumentException("Violation of precondition: " +
"getValueOfMostValuablePlot. The parameter may not be null," +
" must value at least one row and at least" +
" one column, and must be rectangular.");
}
}
Here is testers:
board = new char[][] { { '.', '.', '.', 'q' },
{ '.', '.', '.', '.' },
{ '.', '.', '.', '.' },
{ 'q', '.', '.', '.' } };
expectedBool = false;
board = new char[][] { { 'q', '.', '.', '.', '.', '.', '.' },
{ '.', '.', '.', '.', 'q', '.', '.' },
{ '.', 'q', '.', '.', '.', '.', '.' },
{ '.', '.', '.', '.', '.', 'q', '.' },
{ '.', '.', 'q', '.', '.', '.', '.' },
{ '.', '.', '.', '.', '.', '.', 'q' },
{ '.', '.', '.', 'q', '.', '.', '.' } };
expectedBool = true;
board = new char[][] {
{ 'q', '.', '.', '.', '.', '.', '.', '.', '.', '.' },
{ '.', '.', '.', '.', 'q', '.', '.', '.', '.', '.' },
{ '.', 'q', '.', '.', '.', '.', '.', '.', '.', '.' },
{ '.', '.', '.', '.', '.', 'q', '.', '.', '.', '.' },
{ '.', '.', 'q', '.', '.', '.', '.', '.', '.', '.' },
{ '.', '.', '.', '.', '.', '.', 'q', '.', '.', '.' },
{ '.', '.', '.', 'q', '.', '.', '.', '.', '.', '.' },
{ '.', '.', '.', '.', '.', '.', '.', '.', '.', '.' },
{ '.', '.', '.', '.', '.', '.', '.', '.', '.', '.' },
{ '.', '.', '.', '.', '.', '.', '.', '.', 'q', '.' }, };
expectedBool = false;
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill