Java Programming (Linked List)?

I'm trying to do my assignment, and I'm stuck. I'm writing a code for GameEntry Linked List. Can anyone help me or give me a hint? Below is the method list that should be written in code. public GameEntryList() public void display() public void addFirst(GameEntry entry) public GameEntry... show more I'm trying to do my assignment, and I'm stuck.
I'm writing a code for GameEntry Linked List.

Can anyone help me or give me a hint?

Below is the method list that should be written in code.

public GameEntryList()
public void display()
public void addFirst(GameEntry entry)
public GameEntry removeFirst()

public void addLast(GameEntry entry)
public GameEntry removeLast()
public void add(GameEntry entry)
public GameEntry remove(int i)


and below is the code I wrote.

public class GameEntryList {

private GameEntry head;
private GameEntry tail;
private int size;
/** Constructor
* create an empty linked list.
* */
public GameEntryList(){
head = null;
tail = null;
size = 0;
}
public void display(){
}
public void addFirst(GameEntry entry){
GameEntry newScore = new GameEntry(entry.getName(), entry.getScore());

if(size==0){
head = newScore;
tail = newScore;
}
else
newScore.next = head;
head = newScore;
size++;
}
public GameEntry removeFirst(){
GameEntry curNode = head;
head = head.next;
curNode = null;
return curNode;
}

// inner class
private class GameEntry {

public GameEntry next;
private String name;
private int score;

public GameEntry(String name, int score) {
this.name = name;
this.score = score;
}

public String getName() {
return name;
}

public int getScore() {
return score;
}

public String toString() {
return "[" + name + "," + score + "]";
}
}
public static void main(String args[]){
GameEntryList e = new GameEntryList();

}

}
2 answers 2