Im having a bit of trouble with designing a class. I dont need any help with the code or methods just the design. Here is the scenario, I am asked to design a Combination class, all the Combination class does is take a number and return an ArrayList of Integer containing position, ie 1 would produce an ArrayList containing 1, 2 would return ArrayList containg 2, 3 would return an ArrayList containing 1 2 ect.
Ok the Combination class gets implement as explained, then i have 2 more things i want to do with my combination class. I want to add the option where the user of the class can send a collection of numbers to test against the combination numbers and if it finds they are the same size then zap it, the next option allows the user to send a collection of numbers and check against the numbers in the Combination numbers if one is the same zap it.
The question is then would you put the 2 methods inside the combination class, making the class a bit clunky, make a subclass of combination and place the methods in their or make an interface with these methods for any subclass of combination implement if needed, or any other design im not aware of.
Regarding your combination class, say the number is 5, then you want to build an ArrayList with elements of 1,2,3,4. Am I correct?
If the number is 5 the combination would return the binary representation, i.e 1,3 would be 5. You can think of 1 and 3 as represinting set bits in the binary number 5. I should of been more clear. I was thinking in design terms, the Combination class is quite nice and it seemed a shame to place some obscure methods inside. I need these 2 methods but was wondering how to implement them in a design sense. If push comes to shove they can go inside the combination class. Thanks for your quick reply
That's bit positions of the string representation, something like 0101 from the right-most side?