Results 1 to 4 of 4
Thread: Sorting Arrays by enum
- 11-25-2009, 12:01 AM #1
Member
- Join Date
- Nov 2009
- Posts
- 2
- Rep Power
- 0
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
- 11-25-2009, 09:31 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,479
- Rep Power
- 16
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.
- 11-26-2009, 12:17 AM #3
Member
- Join Date
- Nov 2009
- Posts
- 2
- Rep Power
- 0
thank you,
how do you turn the data into student objects? Can you please give an example?
- 11-26-2009, 09:08 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,479
- Rep Power
- 16
Similar Threads
-
Scanner, while loop and sorting arrays/string?
By RSYR in forum New To JavaReplies: 10Last Post: 04-20-2011, 06:13 PM -
Enum example
By Java Tip in forum java.langReplies: 0Last Post: 04-17-2008, 07:34 PM -
How to use enum
By Java Tip in forum java.langReplies: 0Last Post: 04-17-2008, 07:34 PM -
Enum Error in JDK 1.6
By nani5swamy in forum Advanced JavaReplies: 1Last Post: 01-04-2008, 11:23 PM -
Enum?
By vgbhagavan in forum Advanced JavaReplies: 0Last Post: 06-14-2007, 02:02 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks