How to check and match the possible combinations of arraylist elements

Posted by Jessy on Stack Overflow See other posts from Stack Overflow or by Jessy
Published on 2010-03-31T00:03:27Z Indexed on 2010/03/31 0:13 UTC
Read the original article Hit count: 608

Filed under:
|
|
String [] A = {"High","Medium","Low"};
String [] B = {"High","Medium","Low"};
String [] C = {"High","Medium","Low"};
String [] D = {"High","Medium","Low"};
String [] E = {"High","Medium","Low"};
String [] F = {"High","Medium","Low"};

JComboBox Ai = new JComboBox(A); JComboBox Bi = new JComboBox(B);
JComboBox Ci = new JComboBox(C); JComboBox Di = new JComboBox(C);
JComboBox Ei = new JComboBox(E); JComboBox Fi = new JComboBox(F);

....

//add the user choice in arrayList
ArrayList<String> a = new ArrayList<String>();
a.add((String) Ai.getSelectedItem());
a.add((String) Bi.getSelectedItem());
a.add((String) Ci.getSelectedItem());
a.add((String) Di.getSelectedItem());
a.add((String) Ei.getSelectedItem());
a.add((String) Fi.getSelectedItem());

Scenario: On each comboBox, user need to choose one, which mean there are 6 choices at the end. There are 6*5*4*3*2*1 = 720 possible combinations of choices made by the user.

What is the best way to check and match the user choice without writing the 720 else if ? e.g.

if(Ai=="High" && Bi=="High" && Ci=="Low" && Di=="High" && Ei=="Low" && Fi=="Medium") {
    System.out.println("Good Choice"); 
}

Thank you.

© Stack Overflow or respective owner

Related posts about java

Related posts about arraylist