Results 1 to 4 of 4

Thread: Design Problem

  1. #1
    Join Date
    Dec 2008
    Location
    Manchester England
    Posts
    14
    Rep Power
    0

    Default Design Problem

    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.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    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?

  3. #3
    Join Date
    Dec 2008
    Location
    Manchester England
    Posts
    14
    Rep Power
    0

    Default

    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

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Relay Buffer Flow Design Pattern Problem
    By rushhour in forum Threads and Synchronization
    Replies: 0
    Last Post: 01-13-2011, 01:28 PM
  2. GUI design
    By kennyblue in forum AWT / Swing
    Replies: 6
    Last Post: 11-10-2010, 06:59 PM
  3. Design/code reusage problem
    By turanan in forum New To Java
    Replies: 12
    Last Post: 01-22-2010, 11:27 AM
  4. Netbeans 6.8 GUI design problem
    By newbiejava in forum NetBeans
    Replies: 0
    Last Post: 01-14-2010, 03:02 AM
  5. Java Design Problem
    By hencre in forum Advanced Java
    Replies: 2
    Last Post: 02-25-2009, 08:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •