Answered step by step
Verified Expert Solution
Question
1 Approved Answer
you will construct a list of scores and allow the user to interact with the list. You must use a linked chain that you
you will construct a list of scores and allow the user to interact with the list. You must use a linked chain that you have created yourself. You must create instances of the node class, and connect them together appropriately. Do not use any of the prebuilt classes available in the JDK that create lists already (e.g., LinkedList, ArrayList). You will need 3 classes, all created in a package named proj2: . ScoreNode class This is a single node representing a name, score, and reference to another node ScoreList class This is a class that maintains the actual list of nodes, linked in a chain ScoreDemo class This will be the only class with a main method in it This is the class used for testing the list, interacting with the user, etc. I repeat: ONLY Score Demo should contain a main method. The ScoreNode and ScoreList classes should be independent of any directly executable functionality. ScoreList will require an instance being made inside the demo class, and interactivity from the user, provided by that class. ScoreNode class The ScoreNode class represents an individual score. This requires a name of type String, and a score of type integer, and obviously a reference to the next node in the chain. Scores List class Method Scores List Scores List(Scores List otherList) add(String name, int score) remove(String name); print() Notes No-argument constructor. Sets the ScoreList's linked chain head node (front) to null A copy constructor. This constructor will perform a deep copy on the otherList, making an exact copy of it. Add the name/score value to the linked chain in the correct order based on what is already in the chain (if anything). Remember, you must maintain the list in sorted order, descending. The name will be unique. If you try to add data for a name that already exists in the list, then the score will be updated and a new node will not be created. Given the name, find and remove the name. The print method simply prints out the score list represented by the calling Score List object. Given a ScoreList object, mySL, the call to mySL will simply print out the scores by walking down the linked chain. Assume all printing is done to the console. File Input The file scores.txt will contain, on each line, the name of the player, followed by their high score, such as the following: Bob 150 Dan 220 Samantha 70 Ksenia 175 Nathan 15 The files are, in general, not going to be in a sorted order. The ScoresList class should, as you add the names and corresponding scores from file, keep them in descending (largest to smallest) order in the linked chain of nodes. Corresponding Console Output and User Interaction For the above file, the output will display the high scores in sorted order from highest to lowest, and interaction with the user might look like the following: Dan 220 Ksenia 175 Bob 150 Samantha 70 Nathan 15 Would you like to add another (1), remove (2), or quit the program (3)? 1 Write the name followed by score Ali 190 The new scores are: Dan 220 Ali 190 Ksenia 175 Bob 150 Samantha 70 Nathan 15 Would you like to add another (1), remove (2), or quit the program (3)? 1 Write the name of the person you'd like to remove Samantha The new scores are: Dan 220 Ali 190 Ksenia 175 Bob 150 Nathan 15 Would you like to add another (1) or quit the program (2)? 3 Thanks for using the program! Goodbye! The output, including additions made by the user, do not affect the original file. They only change the in-memory copy of the ScoreList. You continue asking the user if they'd like to add another or quit the program until they ask to quit the program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
The problem is to organize classes to do the given tasks Implementation import javaioFile import javaioFileNotFoundException import javautilScanner class ScoreNode String name int score ScoreNode next ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started