Skip to main content
Logo image

Section 10.9 ArrayTester - Part B

Part b. Write the static method isLatin, which returns true if a given two-dimensional square array is a Latin square, and otherwise, returns false.
A two-dimensional square array of integers is a Latin square if the following conditions are true. 1) The first row has no duplicate values. 2) All values in the first row of the square appear in each row of the square. 3) All values in the first row of the square appear in each column of the square.
Figure 10.9.1.
The ArrayTester class provides two helper methods: containsDuplicates and hasAllValues. The method containsDuplicates returns true if the given one-dimensional array arr contains any duplicate values and false otherwise. The method hasAllValues returns true if and only if every value in arr1 appears in arr2. You do not need to write the code for these methods.
Figure 10.9.2.
Complete method isLatin below. Assume that getColumn works as specified, regardless of what you wrote in part (a). You must use getColumn, hasAllValues, and containsDuplicates appropriately to receive full credit.

Subsection 10.9.1 Try and Solve It

Activity 10.9.1.

Complete the method isLatin below.
You have attempted of activities on this page.