I want to include a method in Object1, which will take a search term as a parameter and will then iterate through the arraylist of objects2. Through every iteration, it will need to compare the search term against every variable the object has (It has 5 different variable). For example :

The user inputs a search term, the system will then iterate through the arraylists of objects. The first object in the arraylist, it will compare the 5 variables of that object with the search term, and if there is a single match, it will print that object. It will then move on to the second object in the array list and do the same...

I'm not quite sure how to implement this in a nice readable way. The only way I can think of is implementing multiple IF OR OR statements...

Any ideas ? Any help is appreciated, thanks! ]]>

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class LatinSquare

{

public static void main(String args[])

{

int matrix[][] = initMatrix();

printData(matrix);

if(latinSquare(matrix))

{

System.out.println("This is a Latin Square");

}

else

{

System.out.println("This is not a Latin Square");

}

}

public static boolean latinSquare(int[][] array)

{

for (int i = 0; i<array.length ;i++)

{

if(duplicates(array[i]))

{

return false;

}

int[] column = new int[array[i].length];

for(int j = 0; j<array.length; j++)

{

column[j] = array[i][j];

}

if(duplicates(column))

{

return false;

}

}

return true;

}

public static boolean duplicates(int[] array)

{

for (int i = 0; i<array.length; i++)

{

for(int j = 0; j<array.length; j++)

{

if (i != j && array[i] == array[j])

{

return true;

}

}

}

return false;

}

public static int[][] initMatrix()

{

int matrix[][];

Scanner filein = null;

try

{

filein = new Scanner(new File("matrix.txt"));

int numRows = Integer.parseInt(filein.nextLine());

matrix = new int[numRows][];

parseData(matrix, filein);

filein.close();

return matrix;

}

catch (FileNotFoundException e)

{

System.out.println(e.getMessage());

if(filein != null)

{

filein.close();

}

return null;

}

}

public static void parseData(int matrix[][], Scanner in)

{

for(int r = 0; r < matrix.length; r++)

{

String splitLine[] = in.nextLine().split(" ");

matrix[r] = new int[splitLine.length];

for(int c = 0; c < matrix[r].length; c++)

{

matrix[r][c] = Integer.parseInt(splitLine[c]);

}

}

}

public static void printData(int matrix[][])

{

for(int r = 0; r < matrix.length; r++)

{

for(int c = 0; c < matrix[r].length; c++)

{

System.out.print(matrix[r][c] + " ");

}

System.out.println();

}

}

}

The matrix.txt contains the following info

3

1 2 3

3 2 1

2 3 1 ]]>