12-04-2013

posted Dec 3, 2013, 11:32 AM by Samuel Konstantinovich   [ updated Dec 3, 2013, 11:33 AM ]
Work on your WordGrid object you should implement horizontal, vertical, and both upDiagonal and downDiagonal.
Complete this by tomorrow.

Practice problems: 

Remember row vs col:
                 Col 0     Col 1   Col 2
Row 0        a[0][0]   a[0][1] a[0][2]
Row 1        a[1][0]   a[1][1] a[1][2]
Row 2        a[2][0]   a[2][1] a[2][2]
Row 3        a[3][0]   a[3][1] a[3][2]

Practice methods you can write to do better on the next quiz or test:

public static int max(int[][] AR) 
   returns the maximum value in the 2d parameter array AR.

public static int rowSum(int[][] AR, int x)
   returns the sum of the elements in Row x of AR. 

public static int columnSum(int[][] AR, int x)
   returns the sum of the elements in Column x of AR (careful with rows of different lengths!).

public static int[] allRowSums(int[][] AR)
   calculates the row sum for every row and returns each of the values in an array. Index i of the return array contains the sum of elements in row i.

public static boolean isRowMagic(int[][] AR)
   checks if the array is row-magic (this means that every row has the same row sum).

public static boolean isColumnMagic(int[][] AR)
   checks if the array is column-magic (this means that every column has the same column sum).

public static boolean isSquare(int[][] AR)
   checks if the array is square (i.e. every row has the same length as AR itself).
Comments