0

any one know how to make a combination from user input like that : User chose some options like

Size:L,XL,XXL,... AND|OR 
Color: red,green,black,... AND|OR 
ANY_OTHER_OPTION : VALUE_1,VALUE_2,... 

size my be nothing and other options also

i need the output to be like

L.red.VALUE_1
L.red.VALUE_2
L.green.VALUE_1
L.green.VALUE_2
L.black.VALUE_1
L.black.VALUE_2
XL.red.VALUE_1
XL.red.VALUE_2
XL.green.VALUE_1
XL.green.VALUE_2
XL.black.VALUE_1
XL.black.VALUE_2
XXL.red.VALUE_1
XXL.red.VALUE_2
XXL.green.VALUE_1
XXL.green.VALUE_2
XXL.black.VALUE_1
XXL.black.VALUE_2

any best practice for that combination ??

Samir Ghoneim
  • 591
  • 1
  • 6
  • 14

1 Answers1

0

Assuming that the options are stored in arrays, here is the code you want:

String[] sizes = {"L", "XL", "XXL"};
String[] colors = {"red", "green", "black"};
String[] others = {"VALUE_1", "VALUE_2"};

for (int i=0; i < sizes.length; i++){
    for (int j=0; j < colors.length; j++){
        for (int k=0; k < others.length; k++){
            System.out.println(sizes[i] + "." + colors[j] + "." + others[k]);
        }
    }
}
Thanasis1101
  • 1,614
  • 4
  • 17
  • 28