Top Ten list for a Trivia game

Hi ALL!!!!

I LOVE this Java thing, it is STARTING to make sense to me and I am loving it! Just finished another semester of it and am excited that the concepts are finally starting to take shape.

With that being said, I have set out to create a simple Trivia game using a Swing Gui ((( Help with good layout question to follow later))).

So far I have setup the program to read questions from a text file randomly, making sure the question has not already been asked. I have the score setup and still have the 3 missed questions method before game over to do.

HERE IS MY QUESTION: I want to make a Top Ten scores list in the interface. My initial thoughts have been to use a text file and append it when a new player breaks a top ten score. ((Also to read it into the Gui through and iteration - while making JLabels out of the Name and score.BUT I am not thinking this is the best or easiest way to do this. Because I not only have to read the scores and decide if the newest score is higher and then append the file BUT then I have to ReORDER all the scores.

We touched briefly on Linked lists in my last class. This sounds like it might work better - but how would I keep the scores in the memory? Maybe keep them in a text file, pull them out into a linked list? Then use that to do any manuevering and adding to the interface that I need to?

** Any help?

[1402 byte] By [tvance929a] at [2007-11-26 20:21:30]
# 1
Yep.
corlettka at 2007-7-10 0:46:19 > top of Java-index,Java Essentials,New To Java...
# 2
informative.
tvance929a at 2007-7-10 0:46:19 > top of Java-index,Java Essentials,New To Java...
# 3

At startup time, read the scores from the file

http://java.sun.com/docs/books/tutorial/essential/io/index.html

Put them into either a SortedSet (like TreeSet), which stays sorted as you insert and remove element, or just a List that you explicitly sort using Collections.sort whenever you need to.

http://java.sun.com/docs/books/tutorial/collections/

Then, when the game is done write the list back out, but NOT in append mode--just ovewrite the old file with the current high scores.

[url=http://www.onjava.com/lpt/a/3286]Making Java Objects Comparable[/url]

http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html

http://www.javaworld.com/javaworld/jw-12-2002/jw-1227-sort.html

jverda at 2007-7-10 0:46:19 > top of Java-index,Java Essentials,New To Java...
# 4
SOUNDS GREAT! Thanks JVerd!!!
tvance929a at 2007-7-10 0:46:19 > top of Java-index,Java Essentials,New To Java...