Let say we have the fallowing classes ‘X’,’Y’,’Z’,
The result so I need will be like this
(X),(X,Y),(X,Z),(X,Y,Z),(Y),(Y,Z),(Z)
And if we have ‘X’,’Y’,’Z’,’J’,
The result so I need will be like this
(X), (X,Y),(X,Z),(X,J), (Y), (Y,Z),(Y,J), (Z),(Z,J)
(X,Y,Z), (X,Y,Z,J), (Y,Z,J), (Z,J,X)
What algorithm do I need to accomplish this?
What you are looking for is called a power set. There are both recursive and iterative ways to calculate it; it should not be difficult to google one.
Have a try at implementing an algorithm and come back to update the question if you have specific trouble.