SlideShare a Scribd company logo
1 of 12
Download to read offline
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD
OR REMOVE NAME. DO NOT HARD CODE NAME. AGAIN MAKE SURE THE
PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR REMOVE NAME. PLEASE
MAKE SURE THE CODE RUNS WITHOUT ANY ERRORS.
Write a class that maintains the scores for a game application. Implement the addition and
removal function to update the database. The gamescore.txt contains player’ name and score data
record fields separated by comma. For Removal function, uses the name field to select record to
remove the game score record.
Use the List.java, LList.java, Dlink.java, GameEntry.java and gamescore.txt found below
Read gamescore.txt to initialize the Linked list in sorted order by score.
Ask the user to add or remove users to update the sorted linked list.
Display “Name exist” when add an exist name to the list.
Display “Name does not exist” when remove a name not on the list.
List.java File:
/** Source code example for "A Practical Introduction to Data
Structures and Algorithm Analysis, 3rd Edition (Java)"
by Clifford A. Shaffer
Copyright 2008-2011 by Clifford A. Shaffer
*/
/** List ADT */
public interface List
{
/**
* Remove all contents from the list, so it is once again empty. Client is
* responsible for reclaiming storage used by the list elements.
*/
public void clear();
/**
* Insert an element at the current location. The client must ensure that
* the list's capacity is not exceeded.
*
* @param item
* The element to be inserted.
*/
public void insert(E item);
/**
* Append an element at the end of the list. The client must ensure that
* the list's capacity is not exceeded.
*
* @param item
* The element to be appended.
*/
public void append(E item);
/**
* Remove and return the current element.
*
* @return The element that was removed.
*/
public E remove();
/** Set the current position to the start of the list */
public void moveToStart();
/** Set the current position to the end of the list */
public void moveToEnd();
/**
* Move the current position one step left. No change if already at
* beginning.
*/
public void prev();
/**
* Move the current position one step right. No change if already at end.
*/
public void next();
/** @return The number of elements in the list. */
public int length();
/** @return The position of the current element. */
public int currPos();
/**
* Set current position.
*
* @param pos
* The position to make current.
*/
public void moveToPos(int pos);
/** @return The current element. */
public E getValue();
}
LList.java File:
/**
* Source code example for "A Practical Introduction to Data Structures and
* Algorithm Analysis, 3rd Edition (Java)" by Clifford A. Shaffer Copyright
* 2008-2011 by Clifford A. Shaffer
*/
// Doubly linked list implementation
class LList implements List
{
private DLink head; // Pointer to list header
private DLink tail; // Pointer to last element in list
protected DLink curr; // Pointer ahead of current element
int cnt; // Size of list
// Constructors
LList(int size)
{
this();
} // Ignore size
LList()
{
curr = head = new DLink(null, null); // Create header node
tail = new DLink(head, null);
head.setNext(tail);
cnt = 0;
}
public void clear()
{ // Remove all elements from list
head.setNext(null); // Drop access to rest of links
curr = head = new DLink(null, null); // Create header node
tail = new DLink(head, null);
head.setNext(tail);
cnt = 0;
}
public void moveToStart() // Set curr at list start
{
curr = head;
}
public void moveToEnd() // Set curr at list end
{
curr = tail.prev();
}
/** Insert "it" at current position */
public void insert(E it)
{
curr.setNext(new DLink(it, curr, curr.next()));
curr.next().next().setPrev(curr.next());
cnt++;
}
/** Append "it" to list */
public void append(E it)
{
tail.setPrev(new DLink(it, tail.prev(), tail));
tail.prev().prev().setNext(tail.prev());
cnt++;
}
/** Remove and return current element */
public E remove()
{
if (curr.next() == tail)
return null; // Nothing to remove
E it = curr.next().element(); // Remember value
curr.next().next().setPrev(curr);
curr.setNext(curr.next().next()); // Remove from list
cnt--; // Decrement the count
return it; // Return value removed
}
/** Move curr one step left; no change if at front */
public void prev()
{
if (curr != head) // Can't back up from list head
curr = curr.prev();
}
// Move curr one step right; no change if at end
public void next()
{
if (curr != tail.prev())
curr = curr.next();
}
public int length()
{
return cnt;
}
// Return the position of the current element
public int currPos()
{
DLink temp = head;
int i;
for (i = 0; curr != temp; i++)
temp = temp.next();
return i;
}
// Move down list to "pos" position
public void moveToPos(int pos)
{
assert (pos >= 0) && (pos <= cnt) : "Position out of range";
curr = head;
for (int i = 0; i < pos; i++)
curr = curr.next();
}
public E getValue()
{
// Return current element
if (curr.next() == tail)
return null;
return curr.next().element();
}
// reverseList() method that reverses the LList
public void reverseList()
{
LList revList = new LList();
curr = tail.prev();
while (curr != head)
{
revList.append(curr.element());
curr = curr.prev();
}
head.setNext(revList.head.next());
}
// Extra stuff not printed in the book.
/**
* Generate a human-readable representation of this list's contents that
* looks something like this: < 1 2 3 | 4 5 6 >. The vertical bar
* represents the current location of the fence. This method uses
* toString() on the individual elements.
*
* @return The string representation of this list
*/
public String toString()
{
// Save the current position of the list
int oldPos = currPos();
int length = length();
StringBuffer out = new StringBuffer((length() + 1) * 4);
moveToStart();
out.append("< ");
for (int i = 0; i < oldPos; i++)
{
if (getValue() != null)
{
out.append(getValue());
out.append(" ");
}
next();
}
out.append("| ");
for (int i = oldPos; i < length; i++)
{
out.append(getValue());
out.append(" ");
next();
}
out.append(">");
moveToPos(oldPos); // Reset the fence to its original position
return out.toString();
}
}
DLink.java File:
/** Source code example for "A Practical Introduction to Data
Structures and Algorithm Analysis, 3rd Edition (Java)"
by Clifford A. Shaffer
Copyright 2008-2011 by Clifford A. Shaffer
*/
/** Doubly linked list node */
class DLink
{
private E element; // Value for this node
private DLink next; // Pointer to next node in list
private DLink prev; // Pointer to previous node
/** Constructors */
DLink(E it, DLink p, DLink n)
{
element = it;
prev = p;
next = n;
}
DLink(DLink p, DLink n)
{
prev = p;
next = n;
}
/** Get and set methods for the data members */
DLink next()
{
return next;
}
DLink setNext(DLink nextval)
{
return next = nextval;
}
DLink prev()
{
return prev;
}
DLink setPrev(DLink prevval)
{
return prev = prevval;
}
E element()
{
return element;
}
E setElement(E it)
{
return element = it;
}
}
GameEntry.java File:
public class GameEntry {
protected String name;
protected int score;
public GameEntry(String n, int s) {
name = n;
score = s;
}
public String getName() {return name;}
public int getScore() {return score;}
public String toString() {
return "("+name+","+score+")";
}
}
gamescore.txt File:
Mike,1105
Rob,750
Paul,720
Anna,660
Rose,590
Jack,510
Solution
PROGRAM CODE:
GameSimulator.java
package list;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class GameSimulator {
public static void main(String[] args) {
Scanner filereader;
try {
filereader = new Scanner(new File("gamescore.txt"));
GameApplication application = new GameApplication(20);
while(filereader.hasNextLine())
{
String next = filereader.next();
int index = next.indexOf(",");
String tokens[] = new String[2];
tokens[0] = next.substring(0, index);
tokens[1] = next.substring(index+1, next.length());
GameEntry entry = new GameEntry(tokens[0], Integer.parseInt(tokens[1]));
application.add(entry);
}
System.out.println("After adding from file:");
application.print();
String option = "Y";
while(option.charAt(0)=='Y' || option.charAt(0) == 'y')
{
Scanner keyboard = new Scanner(System.in);
System.out.print("1. Add 2. Remove Enter your choice: ");
int choice = Integer.parseInt(keyboard.nextLine());
String name;
int score;
if(choice == 1)
{
System.out.print("Enter the name: ");
name = keyboard.nextLine();
System.out.print("Enter the score: ");
score = Integer.parseInt(keyboard.nextLine());
GameEntry entry = new GameEntry(name, score);
application.add(entry);
application.print();
}
else if(choice == 2)
{
System.out.print("Enter the name: ");
name = keyboard.nextLine();
application.remove(name);
application.print();
}
else
System.out.println("Invalid choice");
System.out.print("Try Again: (Y/N): ");
option = keyboard.next();
}
} catch (FileNotFoundException e) {
System.out.println("The mentioned file is not found.");
System.exit(0);
}
}
}
GameApplication.java
package list;
public class GameApplication {
LList entries;
public GameApplication(int size) {
entries = new LList(size);
}
private boolean checkDuplicates(String name)
{
boolean isPresent = false;
for(int i=0; ientry.getScore())
{
entries.insert(entry);
break;
}
else if(counter==entries.length())
{
entries.append(entry);
break;
}
else entries.next();
}
}
}
public void remove(String name)
{
//checking if the name exits or not
if(!checkDuplicates(name))
{
System.out.println("Name does not exist");
return;
}
for(int i=0; i
1. Add
2. Remove
Enter your choice: 1
Enter the name: Jack
Enter the score: 320
Name exist
< | (Jack,510) (Rose,590) (Anna,660) (Paul,720) (Rob,750) (Mike,1105) >
Try Again: (Y/N): Y
1. Add
2. Remove
Enter your choice: 1
Enter the name: Mila
Enter the score: 320
< | (Mila,320) (Jack,510) (Rose,590) (Anna,660) (Paul,720) (Rob,750) (Mike,1105) >
Try Again: (Y/N): Y
1. Add
2. Remove
Enter your choice: 2
Enter the name: Anna
< (Mila,320) (Jack,510) (Rose,590) (Paul,720) (Rob,750) | (Mike,1105) >
Try Again: (Y/N): N

More Related Content

Similar to PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf

File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfConint29
 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfcontact41
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfarrowmobile
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdfafgt2012
 
Complete skeletonimport java.util.ArrayList; public class My.pdf
Complete skeletonimport java.util.ArrayList; public class My.pdfComplete skeletonimport java.util.ArrayList; public class My.pdf
Complete skeletonimport java.util.ArrayList; public class My.pdfarhamnighty
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdffatoryoutlets
 
Using the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdfUsing the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdfmallik3000
 
JAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docx
JAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docxJAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docx
JAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docxGavinUJtMathist
 
Using NetBeansImplement a queue named QueueLL using a Linked List .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfUsing NetBeansImplement a queue named QueueLL using a Linked List .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfsiennatimbok52331
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdffreddysarabia1
 
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdf
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdfJAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdf
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdfsuresh640714
 
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfComplete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfrajkumarm401
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfARCHANASTOREKOTA
 
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxNew folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxcurwenmichaela
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdffantasiatheoutofthef
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfseoagam1
 
(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf
(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf
(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdfarihantmobileselepun
 
C++ projectMachine Problem 7 - HashingWrite a program to do the .pdf
C++ projectMachine Problem 7 - HashingWrite a program to do the .pdfC++ projectMachine Problem 7 - HashingWrite a program to do the .pdf
C++ projectMachine Problem 7 - HashingWrite a program to do the .pdffeelinggift
 
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docxhoney725342
 
This is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfThis is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfinfo334223
 

Similar to PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf (20)

File LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdfFile LinkedList.java Defines a doubly-l.pdf
File LinkedList.java Defines a doubly-l.pdf
 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdf
 
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdfHere is the editable codeSolutionimport java.util.NoSuchEleme.pdf
Here is the editable codeSolutionimport java.util.NoSuchEleme.pdf
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
 
Complete skeletonimport java.util.ArrayList; public class My.pdf
Complete skeletonimport java.util.ArrayList; public class My.pdfComplete skeletonimport java.util.ArrayList; public class My.pdf
Complete skeletonimport java.util.ArrayList; public class My.pdf
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdf
 
Using the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdfUsing the C++ programming language1. Implement the UnsortedList cl.pdf
Using the C++ programming language1. Implement the UnsortedList cl.pdf
 
JAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docx
JAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docxJAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docx
JAVA Demonstrate the use of your APL in a PartB_Driver class by doing.docx
 
Using NetBeansImplement a queue named QueueLL using a Linked List .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdfUsing NetBeansImplement a queue named QueueLL using a Linked List .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdf
 
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdfLabprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
Labprogram.javaLinkedList.javaimport java.util.NoSuchElementEx.pdf
 
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdf
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdfJAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdf
JAVA helpNeed bolded lines fixed for it to compile. Thank you!pu.pdf
 
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfComplete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
 
StackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdfStackInterface An interface for the ADT stack. Do not modif.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
 
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docxNew folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
 
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdfJAVA OOP project; desperately need help asap im begging.Been stuck.pdf
JAVA OOP project; desperately need help asap im begging.Been stuck.pdf
 
Please help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdfPlease help me to make a programming project I have to sue them today- (1).pdf
Please help me to make a programming project I have to sue them today- (1).pdf
 
(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf
(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf
(1)Objective Binary Search Tree traversal (2 points)Use traversal.pdf
 
C++ projectMachine Problem 7 - HashingWrite a program to do the .pdf
C++ projectMachine Problem 7 - HashingWrite a program to do the .pdfC++ projectMachine Problem 7 - HashingWrite a program to do the .pdf
C++ projectMachine Problem 7 - HashingWrite a program to do the .pdf
 
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
03.DS_Store__MACOSX03._.DS_Store03A2.DS_Store__.docx
 
This is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdfThis is the main file include itemh include itemList.pdf
This is the main file include itemh include itemList.pdf
 

More from mallik3000

Explain how The Capitol Building (in D.C.) is a reflection of Greco-.pdf
Explain how The Capitol Building (in D.C.) is a reflection of Greco-.pdfExplain how The Capitol Building (in D.C.) is a reflection of Greco-.pdf
Explain how The Capitol Building (in D.C.) is a reflection of Greco-.pdfmallik3000
 
Exercise 14-3GURLEY CORPORATION Comparative Condensed Balance Sh.pdf
Exercise 14-3GURLEY CORPORATION Comparative Condensed Balance Sh.pdfExercise 14-3GURLEY CORPORATION Comparative Condensed Balance Sh.pdf
Exercise 14-3GURLEY CORPORATION Comparative Condensed Balance Sh.pdfmallik3000
 
estion 5 of 34 Sapling Learning Which is the correct name of the fo.pdf
estion 5 of 34 Sapling Learning Which is the correct name of the fo.pdfestion 5 of 34 Sapling Learning Which is the correct name of the fo.pdf
estion 5 of 34 Sapling Learning Which is the correct name of the fo.pdfmallik3000
 
Discuss the difference between the two levels of moral development. .pdf
Discuss the difference between the two levels of moral development. .pdfDiscuss the difference between the two levels of moral development. .pdf
Discuss the difference between the two levels of moral development. .pdfmallik3000
 
Diels-Alder Post-lab questions F17. 1) Why do the methylene protons.pdf
Diels-Alder Post-lab questions F17. 1) Why do the methylene protons.pdfDiels-Alder Post-lab questions F17. 1) Why do the methylene protons.pdf
Diels-Alder Post-lab questions F17. 1) Why do the methylene protons.pdfmallik3000
 
Create a Balance Sheet to record the following transactions for Tayl.pdf
Create a Balance Sheet to record the following transactions for Tayl.pdfCreate a Balance Sheet to record the following transactions for Tayl.pdf
Create a Balance Sheet to record the following transactions for Tayl.pdfmallik3000
 
Compare Plato and Aristotles philosophies of mathematics and relat.pdf
Compare Plato and Aristotles philosophies of mathematics and relat.pdfCompare Plato and Aristotles philosophies of mathematics and relat.pdf
Compare Plato and Aristotles philosophies of mathematics and relat.pdfmallik3000
 
Choose one of the evolutions of Critical Incident Technique (CIT) an.pdf
Choose one of the evolutions of Critical Incident Technique (CIT) an.pdfChoose one of the evolutions of Critical Incident Technique (CIT) an.pdf
Choose one of the evolutions of Critical Incident Technique (CIT) an.pdfmallik3000
 
Change the creature in this java program to a different one .pdf
Change the creature in this java program to a different one .pdfChange the creature in this java program to a different one .pdf
Change the creature in this java program to a different one .pdfmallik3000
 
Canon Corporation had the following static budget at the beginning o.pdf
Canon Corporation had the following static budget at the beginning o.pdfCanon Corporation had the following static budget at the beginning o.pdf
Canon Corporation had the following static budget at the beginning o.pdfmallik3000
 
Can someone please prove this equation is an identity. Cos^2.pdf
Can someone please prove this equation is an identity. Cos^2.pdfCan someone please prove this equation is an identity. Cos^2.pdf
Can someone please prove this equation is an identity. Cos^2.pdfmallik3000
 
Write a program that finds the max binary tree height. (This is an ex.pdf
Write a program that finds the max binary tree height. (This is an ex.pdfWrite a program that finds the max binary tree height. (This is an ex.pdf
Write a program that finds the max binary tree height. (This is an ex.pdfmallik3000
 
What happens when the JVM encounters a wait () callSolution=.pdf
What happens when the JVM encounters a wait () callSolution=.pdfWhat happens when the JVM encounters a wait () callSolution=.pdf
What happens when the JVM encounters a wait () callSolution=.pdfmallik3000
 
Write a program in c++ that maintains a telephone directory. The Tel.pdf
Write a program in c++ that maintains a telephone directory. The Tel.pdfWrite a program in c++ that maintains a telephone directory. The Tel.pdf
Write a program in c++ that maintains a telephone directory. The Tel.pdfmallik3000
 
Why are supplies and inventory not considered plant assetsSolut.pdf
Why are supplies and inventory not considered plant assetsSolut.pdfWhy are supplies and inventory not considered plant assetsSolut.pdf
Why are supplies and inventory not considered plant assetsSolut.pdfmallik3000
 
What is the major purpose of the Federal Reserve System What is the.pdf
What is the major purpose of the Federal Reserve System What is the.pdfWhat is the major purpose of the Federal Reserve System What is the.pdf
What is the major purpose of the Federal Reserve System What is the.pdfmallik3000
 
What is the role of culture in leader development What culture fact.pdf
What is the role of culture in leader development What culture fact.pdfWhat is the role of culture in leader development What culture fact.pdf
What is the role of culture in leader development What culture fact.pdfmallik3000
 
What methods can IT use to make sure its initiatives have the suppor.pdf
What methods can IT use to make sure its initiatives have the suppor.pdfWhat methods can IT use to make sure its initiatives have the suppor.pdf
What methods can IT use to make sure its initiatives have the suppor.pdfmallik3000
 
What is IT infrastructure, and what are the stages and drivers of IT.pdf
What is IT infrastructure, and what are the stages and drivers of IT.pdfWhat is IT infrastructure, and what are the stages and drivers of IT.pdf
What is IT infrastructure, and what are the stages and drivers of IT.pdfmallik3000
 
What is the difference between a dinoflagellate and a Stramenopi.pdf
What is the difference between a dinoflagellate and a Stramenopi.pdfWhat is the difference between a dinoflagellate and a Stramenopi.pdf
What is the difference between a dinoflagellate and a Stramenopi.pdfmallik3000
 

More from mallik3000 (20)

Explain how The Capitol Building (in D.C.) is a reflection of Greco-.pdf
Explain how The Capitol Building (in D.C.) is a reflection of Greco-.pdfExplain how The Capitol Building (in D.C.) is a reflection of Greco-.pdf
Explain how The Capitol Building (in D.C.) is a reflection of Greco-.pdf
 
Exercise 14-3GURLEY CORPORATION Comparative Condensed Balance Sh.pdf
Exercise 14-3GURLEY CORPORATION Comparative Condensed Balance Sh.pdfExercise 14-3GURLEY CORPORATION Comparative Condensed Balance Sh.pdf
Exercise 14-3GURLEY CORPORATION Comparative Condensed Balance Sh.pdf
 
estion 5 of 34 Sapling Learning Which is the correct name of the fo.pdf
estion 5 of 34 Sapling Learning Which is the correct name of the fo.pdfestion 5 of 34 Sapling Learning Which is the correct name of the fo.pdf
estion 5 of 34 Sapling Learning Which is the correct name of the fo.pdf
 
Discuss the difference between the two levels of moral development. .pdf
Discuss the difference between the two levels of moral development. .pdfDiscuss the difference between the two levels of moral development. .pdf
Discuss the difference between the two levels of moral development. .pdf
 
Diels-Alder Post-lab questions F17. 1) Why do the methylene protons.pdf
Diels-Alder Post-lab questions F17. 1) Why do the methylene protons.pdfDiels-Alder Post-lab questions F17. 1) Why do the methylene protons.pdf
Diels-Alder Post-lab questions F17. 1) Why do the methylene protons.pdf
 
Create a Balance Sheet to record the following transactions for Tayl.pdf
Create a Balance Sheet to record the following transactions for Tayl.pdfCreate a Balance Sheet to record the following transactions for Tayl.pdf
Create a Balance Sheet to record the following transactions for Tayl.pdf
 
Compare Plato and Aristotles philosophies of mathematics and relat.pdf
Compare Plato and Aristotles philosophies of mathematics and relat.pdfCompare Plato and Aristotles philosophies of mathematics and relat.pdf
Compare Plato and Aristotles philosophies of mathematics and relat.pdf
 
Choose one of the evolutions of Critical Incident Technique (CIT) an.pdf
Choose one of the evolutions of Critical Incident Technique (CIT) an.pdfChoose one of the evolutions of Critical Incident Technique (CIT) an.pdf
Choose one of the evolutions of Critical Incident Technique (CIT) an.pdf
 
Change the creature in this java program to a different one .pdf
Change the creature in this java program to a different one .pdfChange the creature in this java program to a different one .pdf
Change the creature in this java program to a different one .pdf
 
Canon Corporation had the following static budget at the beginning o.pdf
Canon Corporation had the following static budget at the beginning o.pdfCanon Corporation had the following static budget at the beginning o.pdf
Canon Corporation had the following static budget at the beginning o.pdf
 
Can someone please prove this equation is an identity. Cos^2.pdf
Can someone please prove this equation is an identity. Cos^2.pdfCan someone please prove this equation is an identity. Cos^2.pdf
Can someone please prove this equation is an identity. Cos^2.pdf
 
Write a program that finds the max binary tree height. (This is an ex.pdf
Write a program that finds the max binary tree height. (This is an ex.pdfWrite a program that finds the max binary tree height. (This is an ex.pdf
Write a program that finds the max binary tree height. (This is an ex.pdf
 
What happens when the JVM encounters a wait () callSolution=.pdf
What happens when the JVM encounters a wait () callSolution=.pdfWhat happens when the JVM encounters a wait () callSolution=.pdf
What happens when the JVM encounters a wait () callSolution=.pdf
 
Write a program in c++ that maintains a telephone directory. The Tel.pdf
Write a program in c++ that maintains a telephone directory. The Tel.pdfWrite a program in c++ that maintains a telephone directory. The Tel.pdf
Write a program in c++ that maintains a telephone directory. The Tel.pdf
 
Why are supplies and inventory not considered plant assetsSolut.pdf
Why are supplies and inventory not considered plant assetsSolut.pdfWhy are supplies and inventory not considered plant assetsSolut.pdf
Why are supplies and inventory not considered plant assetsSolut.pdf
 
What is the major purpose of the Federal Reserve System What is the.pdf
What is the major purpose of the Federal Reserve System What is the.pdfWhat is the major purpose of the Federal Reserve System What is the.pdf
What is the major purpose of the Federal Reserve System What is the.pdf
 
What is the role of culture in leader development What culture fact.pdf
What is the role of culture in leader development What culture fact.pdfWhat is the role of culture in leader development What culture fact.pdf
What is the role of culture in leader development What culture fact.pdf
 
What methods can IT use to make sure its initiatives have the suppor.pdf
What methods can IT use to make sure its initiatives have the suppor.pdfWhat methods can IT use to make sure its initiatives have the suppor.pdf
What methods can IT use to make sure its initiatives have the suppor.pdf
 
What is IT infrastructure, and what are the stages and drivers of IT.pdf
What is IT infrastructure, and what are the stages and drivers of IT.pdfWhat is IT infrastructure, and what are the stages and drivers of IT.pdf
What is IT infrastructure, and what are the stages and drivers of IT.pdf
 
What is the difference between a dinoflagellate and a Stramenopi.pdf
What is the difference between a dinoflagellate and a Stramenopi.pdfWhat is the difference between a dinoflagellate and a Stramenopi.pdf
What is the difference between a dinoflagellate and a Stramenopi.pdf
 

Recently uploaded

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 

Recently uploaded (20)

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 

PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf

  • 1. PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR REMOVE NAME. DO NOT HARD CODE NAME. AGAIN MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR REMOVE NAME. PLEASE MAKE SURE THE CODE RUNS WITHOUT ANY ERRORS. Write a class that maintains the scores for a game application. Implement the addition and removal function to update the database. The gamescore.txt contains player’ name and score data record fields separated by comma. For Removal function, uses the name field to select record to remove the game score record. Use the List.java, LList.java, Dlink.java, GameEntry.java and gamescore.txt found below Read gamescore.txt to initialize the Linked list in sorted order by score. Ask the user to add or remove users to update the sorted linked list. Display “Name exist” when add an exist name to the list. Display “Name does not exist” when remove a name not on the list. List.java File: /** Source code example for "A Practical Introduction to Data Structures and Algorithm Analysis, 3rd Edition (Java)" by Clifford A. Shaffer Copyright 2008-2011 by Clifford A. Shaffer */ /** List ADT */ public interface List { /** * Remove all contents from the list, so it is once again empty. Client is * responsible for reclaiming storage used by the list elements. */ public void clear(); /** * Insert an element at the current location. The client must ensure that * the list's capacity is not exceeded. * * @param item * The element to be inserted. */ public void insert(E item);
  • 2. /** * Append an element at the end of the list. The client must ensure that * the list's capacity is not exceeded. * * @param item * The element to be appended. */ public void append(E item); /** * Remove and return the current element. * * @return The element that was removed. */ public E remove(); /** Set the current position to the start of the list */ public void moveToStart(); /** Set the current position to the end of the list */ public void moveToEnd(); /** * Move the current position one step left. No change if already at * beginning. */ public void prev(); /** * Move the current position one step right. No change if already at end. */ public void next(); /** @return The number of elements in the list. */ public int length(); /** @return The position of the current element. */ public int currPos(); /** * Set current position. * * @param pos * The position to make current.
  • 3. */ public void moveToPos(int pos); /** @return The current element. */ public E getValue(); } LList.java File: /** * Source code example for "A Practical Introduction to Data Structures and * Algorithm Analysis, 3rd Edition (Java)" by Clifford A. Shaffer Copyright * 2008-2011 by Clifford A. Shaffer */ // Doubly linked list implementation class LList implements List { private DLink head; // Pointer to list header private DLink tail; // Pointer to last element in list protected DLink curr; // Pointer ahead of current element int cnt; // Size of list // Constructors LList(int size) { this(); } // Ignore size LList() { curr = head = new DLink(null, null); // Create header node tail = new DLink(head, null); head.setNext(tail); cnt = 0; } public void clear() { // Remove all elements from list head.setNext(null); // Drop access to rest of links curr = head = new DLink(null, null); // Create header node tail = new DLink(head, null); head.setNext(tail);
  • 4. cnt = 0; } public void moveToStart() // Set curr at list start { curr = head; } public void moveToEnd() // Set curr at list end { curr = tail.prev(); } /** Insert "it" at current position */ public void insert(E it) { curr.setNext(new DLink(it, curr, curr.next())); curr.next().next().setPrev(curr.next()); cnt++; } /** Append "it" to list */ public void append(E it) { tail.setPrev(new DLink(it, tail.prev(), tail)); tail.prev().prev().setNext(tail.prev()); cnt++; } /** Remove and return current element */ public E remove() { if (curr.next() == tail) return null; // Nothing to remove E it = curr.next().element(); // Remember value curr.next().next().setPrev(curr); curr.setNext(curr.next().next()); // Remove from list cnt--; // Decrement the count return it; // Return value removed } /** Move curr one step left; no change if at front */
  • 5. public void prev() { if (curr != head) // Can't back up from list head curr = curr.prev(); } // Move curr one step right; no change if at end public void next() { if (curr != tail.prev()) curr = curr.next(); } public int length() { return cnt; } // Return the position of the current element public int currPos() { DLink temp = head; int i; for (i = 0; curr != temp; i++) temp = temp.next(); return i; } // Move down list to "pos" position public void moveToPos(int pos) { assert (pos >= 0) && (pos <= cnt) : "Position out of range"; curr = head; for (int i = 0; i < pos; i++) curr = curr.next(); } public E getValue() { // Return current element if (curr.next() == tail)
  • 6. return null; return curr.next().element(); } // reverseList() method that reverses the LList public void reverseList() { LList revList = new LList(); curr = tail.prev(); while (curr != head) { revList.append(curr.element()); curr = curr.prev(); } head.setNext(revList.head.next()); } // Extra stuff not printed in the book. /** * Generate a human-readable representation of this list's contents that * looks something like this: < 1 2 3 | 4 5 6 >. The vertical bar * represents the current location of the fence. This method uses * toString() on the individual elements. * * @return The string representation of this list */ public String toString() { // Save the current position of the list int oldPos = currPos(); int length = length(); StringBuffer out = new StringBuffer((length() + 1) * 4); moveToStart(); out.append("< "); for (int i = 0; i < oldPos; i++) { if (getValue() != null) {
  • 7. out.append(getValue()); out.append(" "); } next(); } out.append("| "); for (int i = oldPos; i < length; i++) { out.append(getValue()); out.append(" "); next(); } out.append(">"); moveToPos(oldPos); // Reset the fence to its original position return out.toString(); } } DLink.java File: /** Source code example for "A Practical Introduction to Data Structures and Algorithm Analysis, 3rd Edition (Java)" by Clifford A. Shaffer Copyright 2008-2011 by Clifford A. Shaffer */ /** Doubly linked list node */ class DLink { private E element; // Value for this node private DLink next; // Pointer to next node in list private DLink prev; // Pointer to previous node /** Constructors */ DLink(E it, DLink p, DLink n) { element = it; prev = p; next = n; }
  • 8. DLink(DLink p, DLink n) { prev = p; next = n; } /** Get and set methods for the data members */ DLink next() { return next; } DLink setNext(DLink nextval) { return next = nextval; } DLink prev() { return prev; } DLink setPrev(DLink prevval) { return prev = prevval; } E element() { return element; } E setElement(E it) { return element = it; } } GameEntry.java File: public class GameEntry { protected String name; protected int score; public GameEntry(String n, int s) {
  • 9. name = n; score = s; } public String getName() {return name;} public int getScore() {return score;} public String toString() { return "("+name+","+score+")"; } } gamescore.txt File: Mike,1105 Rob,750 Paul,720 Anna,660 Rose,590 Jack,510 Solution PROGRAM CODE: GameSimulator.java package list; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class GameSimulator { public static void main(String[] args) { Scanner filereader; try { filereader = new Scanner(new File("gamescore.txt")); GameApplication application = new GameApplication(20); while(filereader.hasNextLine()) { String next = filereader.next(); int index = next.indexOf(","); String tokens[] = new String[2];
  • 10. tokens[0] = next.substring(0, index); tokens[1] = next.substring(index+1, next.length()); GameEntry entry = new GameEntry(tokens[0], Integer.parseInt(tokens[1])); application.add(entry); } System.out.println("After adding from file:"); application.print(); String option = "Y"; while(option.charAt(0)=='Y' || option.charAt(0) == 'y') { Scanner keyboard = new Scanner(System.in); System.out.print("1. Add 2. Remove Enter your choice: "); int choice = Integer.parseInt(keyboard.nextLine()); String name; int score; if(choice == 1) { System.out.print("Enter the name: "); name = keyboard.nextLine(); System.out.print("Enter the score: "); score = Integer.parseInt(keyboard.nextLine()); GameEntry entry = new GameEntry(name, score); application.add(entry); application.print(); } else if(choice == 2) { System.out.print("Enter the name: "); name = keyboard.nextLine(); application.remove(name); application.print(); } else System.out.println("Invalid choice"); System.out.print("Try Again: (Y/N): "); option = keyboard.next();
  • 11. } } catch (FileNotFoundException e) { System.out.println("The mentioned file is not found."); System.exit(0); } } } GameApplication.java package list; public class GameApplication { LList entries; public GameApplication(int size) { entries = new LList(size); } private boolean checkDuplicates(String name) { boolean isPresent = false; for(int i=0; ientry.getScore()) { entries.insert(entry); break; } else if(counter==entries.length()) { entries.append(entry); break; } else entries.next(); } } }
  • 12. public void remove(String name) { //checking if the name exits or not if(!checkDuplicates(name)) { System.out.println("Name does not exist"); return; } for(int i=0; i 1. Add 2. Remove Enter your choice: 1 Enter the name: Jack Enter the score: 320 Name exist < | (Jack,510) (Rose,590) (Anna,660) (Paul,720) (Rob,750) (Mike,1105) > Try Again: (Y/N): Y 1. Add 2. Remove Enter your choice: 1 Enter the name: Mila Enter the score: 320 < | (Mila,320) (Jack,510) (Rose,590) (Anna,660) (Paul,720) (Rob,750) (Mike,1105) > Try Again: (Y/N): Y 1. Add 2. Remove Enter your choice: 2 Enter the name: Anna < (Mila,320) (Jack,510) (Rose,590) (Paul,720) (Rob,750) | (Mike,1105) > Try Again: (Y/N): N