Please write this in java using a GUI and follow all instruc

Please write this in java using a GUI and follow all instructions....

Implement a class called Scores that will maintain the top 10 scores for a multi-player video game and a GUI application that you can use to test the functionality of the Scores class. You must use a linked list. A single linked list is fine. Your Scores class must have appropriate constructors, a count property for the number of scores currently in the list, methods as needed to add, remove, search, display scores, etc. The list must be ordered with the highest score at the head of the list and lowest high score at the tail of the list. You may have a permanent “dummy node” to anchor the head of the list if you think that will make linking operations easier. In the event of a tie score, the new person/score will replace the older one. For your list nodes, you will create a class called Score that will store a person’s name, their score and a pointer to the next node. Your graphical user interface must contain controls to allow the user to enter a name and score and then add the score to the list assuming the list isn’t full or the score is higher than (or at least ties) another score in the list. You will also need a list box control to display the contents.

Solution

class Gamelist
{
//node class
private class Node
{
String name;
int score;
Node next;
//Node constructor
Node(String namVal,int scraVal,Node n)
{   
name = namVal;
score = scrVal;
next = n;
}

//constructor
Node(String namVal,int scrVal)
  
{
this(namVal,scrVal,null);

}
}
private Node first;//head
private Node last; //last element in list

//constructor

public GameList()
{
first = null;
last = null;

}
//is Empty method; check
if param first is empty
public boolean isEmpty()
{
return first == null;
}
public int size()   
{
int count = 0;
Node p = first;

while(p !=null)
{
count++;
p = p.next;
}
return count;
}

public String toString()
{
StringBuilder = new StringBuilder();
Node p = first;
Node r = first;
while (p!=null)
{
strBuilder.append(p.name + \" \");
p = p.next;
}
while (r != null)
{
strBuilder.append(r.score + \"\ \");
r = r.next;
}
return strBuilder.toString();
}

public void insert(String name, int score)
{
Node node = new Node(name, score);
final int MAX_LIST_LEN = 10;

if(isEmpty())
{
first = node;
first.next = last;
}

else if(first.score <= node.score)
{
node.next = first;
first = node;
}

else
{
Node frontNode = first;
while(frontNode.score > node.score && frontNode.next != null)
{
frontNode = frontNode.next;
}
node.next = frontNode.next;
frontNode.next = node;
}

if(size() > MAX_LIST_LEN)
{
Node player = first;
for(int i = 0; i < 9; i++)
{
player = player.next;
}
player.next = null;
}
}
}

Please write this in java using a GUI and follow all instructions.... Implement a class called Scores that will maintain the top 10 scores for a multi-player vi
Please write this in java using a GUI and follow all instructions.... Implement a class called Scores that will maintain the top 10 scores for a multi-player vi
Please write this in java using a GUI and follow all instructions.... Implement a class called Scores that will maintain the top 10 scores for a multi-player vi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site