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);
....
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());
Editorial:
Scenario: There are 6 groups (Ai, Bi, Ci, Di, Ei, Fi). In each group there are 3 selections (High (H), Medium (M), Low (L)). The user needs to choose one of 6 groups
The selection may be, for example, โHHHLLLโ or โMMMLLMโ or โHHLLMMโ, etc.
What is the best way to test and match user choices without writing many else if? eg
if(Ai=="High" && Bi=="High" && Ci=="Low" && Di=="High" && Ei=="Low" && Fi=="Medium") {
System.out.println("Good Choice");
}
Thank.
source
share