Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2009
    Posts
    2
    Rep Power
    0

    Default Sorting Arrays by enum

    I need to make a sorting algorithm.

    The program takes an input file that stores the information into an array: the array has student's name and a personality type.

    The personality types are: enum values

    Realistic
    Artistic
    Social
    Conventional

    Then once it takes an array, it sould divide the main array into 4 arrays with the personality types.

    So the new array have all the same personality types and the students name.

    Then I need it to divide the 4 arrays by a number. Then number can change at any time.

    So it looks something like this

    Mary Realistic
    Lisa Artistic
    Bill Artistic
    Jake Realistic
    Loren Conventional
    Mike Social
    Jessica Conventional
    Rick Realistic
    Karen Artistic
    Lily Social
    John Social


    divides into four arrays

    Array 1
    Mary Realistic
    Jake Realistic
    Rick Realistic

    Array 2
    Lisa Artistic
    Bill Artistic
    Karen Artistic

    Array 3
    Lily Social
    John Social
    Mike Social

    Array 4
    Loren Conventional
    Jessica Conventional

    Then they select they want a group with 2 people


    group 1
    Mary, Jake

    group 2
    lisa, Bill

    group3
    lily, john

    group4
    loren, jessica

    That leaves Rick, Karen, Mike.
    so it places

    group 5
    Rick and Karen

    and then place Mike in the first group with Mary and jake

    so it would be

    group 1
    Mary, Jake, Mike

    group 2
    lisa, Bill

    group3
    lily, john

    group4
    loren, jessica

    group 5
    Rick and Karen


    I know the problem is a little long, but I am not sure how to start on it. Any help is very well appreciated.

    Thank You

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

    Default

    Break it down.
    Start by reading the file.
    And turning the data in that into a bunch of Student objects.
    So there's three classes to write there...one to read the file, one which represents a Student, and the third is the enum.

  3. #3
    Join Date
    Nov 2009
    Posts
    2
    Rep Power
    0

    Default

    thank you,

    how do you turn the data into student objects? Can you please give an example?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

    Default

    If you don't know that you really need to go back and look at your notes. Both at constructors and setters.

    And then you can write some code. I assume you have written your Student class by now, since you're asking that question.

Similar Threads

  1. Scanner, while loop and sorting arrays/string?
    By RSYR in forum New To Java
    Replies: 10
    Last Post: 04-20-2011, 07:13 PM
  2. Enum example
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 08:34 PM
  3. How to use enum
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 08:34 PM
  4. Enum Error in JDK 1.6
    By nani5swamy in forum Advanced Java
    Replies: 1
    Last Post: 01-05-2008, 12:23 AM
  5. Enum?
    By vgbhagavan in forum Advanced Java
    Replies: 0
    Last Post: 06-14-2007, 03:02 PM

Posting Permissions

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