Re: Help with linked list
hi joe,
well firstly if i was you i would start getting into the habit of writing down what your problem is:
atm you need to do:
1. Create a class that tracks the name and score of the top 10 gamers using a linked list.
2. Only the top 10 scores will be maintained.
3. New entry should only be add if the score exceeds the lowest score on the list. In that case, the lowest score currently on the list should be dropped to make room for the new entry.
Now you have a clear agenda. first thing you need to do is make a new Class maybe call it scores, in that class have 2 attributes Name and Score and create some getters and setters.
Then when your create a Linkedlist i.e LinkedList <Scores> ScoreList = new LinkedList<Scores>();
from there you just need to do some constraints so you only have 10 scores in the list etc and then your done :D
Re: Help with linked list
Welcome to the forums.
Here is a linkedlist example:
Code Java:
import java.util.LinkedList;
public class SimpleJavaLinkedListExample {
public static void main(String[] args) {
// create LinkedList object
LinkedList lList = new LinkedList();
// add elements to LinkedList
lList.add("1");
lList.add("2");
lList.add("3");
lList.add("4");
lList.add("5");
/*
*
* Please note that primitive values can not be added into LinkedList
*
* directly. They must be converted to their corrosponding wrapper
* class.
*/
System.out.println("LinkedList contains : " + lList);
}
}
LinkedList contains : [1, 2, 3, 4, 5]
Re: Help with linked list