This is a undergraduate Data Structures Project, that has to be done in Java language. PLEASE DONT COPY FROM OTHER INTERNET SOURCES LIKE CHEGG, (THIS HAS HAPPENED BEFORE) I want a unique solution. follow each and every detail and instruction as mentioned in the file. Also stick to exact instructions in the project description. I need the project by the 25/9/2021 12:00 am. It is a strict deadline.
The task of this project is to implement in Java a singly linked list of a specific generic type.
Specification
The project must implement the following specification exactly, which includes identifier names, method signatures, etc. For this project, you will be writing one interface and three java classes.
I've also included the required p2 drvier file.
Project 2 LinkedList The task of this project is to implement in Java a singly linked list of a specific generic type. Specification The project must implement the following specification exactly, which includes identifier names, method signatures, etc. For this project, you will be writing one interface and three java classes, they are as follows: 1. Design a java interface called IDedObject that has following abstract function. int getID() //Returns the ID of the object String printID() //Prints the details of the ID 2. Design a java class MyItem that implements IDedObject interface and has the following class variables and one function named getID() int itemID int itemPrice List
itemDescription int getID() String printID() Implement suitable constructors, getID() function that returns the itemID. printID should print the details of the item in one line. Add any access and other functions necessary. {Note all your data should be private and methods public inside the class) 3. Design a generic singly linked list java class IDedLinkedList to hold objects of the generic type . This AnyType should extend IDedObject. You have to design your own class that does not use any other Java collection API. The linked list class must implement following member functions: (Hint: Class IDedLinkedList ) void makeEmpty(); //empties the linked list AnyType findID(int ID); // Get the generic type to get the particular id and returns AnyType. Don’t remove the object from the list. returns null if the list is empty or ID not found. boolean insertAtFront(AnyType x); // insert at front of list or return false if that ID already exists AnyType deleteFromFront(); // delete and return the record at the front of the list or return null if the list is empty AnyType delete(int ID); // find and delete the record with the given ID or returns null if it isn’t found int printTotal(); // return the sum of ids of all elements currently in the list. if list is empty return -1. In addition to the above methods, you must have a constructor and may have other private methods. 4. Write a java class called P2Driver.java (the file with few lines of code given in elearning) with the main function. This class will take two command line arguments. The first argument will be the input file name and second will be output file name. The input file will be given to the program and the program will generate the output file. This main class will create an instance of IDedLinkedList that holds MyItem objects. The main class can handle the following operations by calling the appropriate methods of IDedLinkedList. i. FindID /// print all details of the item with given ID in a single line, if it is in the list , if not print Null ii. Insert /// Get the magazine details from the input file and add it to the front of the list iii. Delete ///Print the details of the first item on the list and then delete it. If list is empty, print Null. iv. DeleteID /// Print the details of the particular IDed item and then delete it. . If list is empty or item not found, print Null. v. PrintTotal /// Print sum of all item ids in the list, the linkedlist should handle this method. vi. End ///Quit the program. This will be the last command executed from the file The input file contains a sequence of lines. Lines starting with "#" are comments. Other lines have one operation per line: name of the operation, followed by parameters needed for that operation (separated by spaces). Lines with Insert operation will have a "0" at the end that is not part of the description. Each file will “End” as last line indicating end of the input file. Sample Input File Insert 22 19 475 1238 9742 0 # New item with id=22, price="$19", description="475 1238 9742" # Return: True # Insert 12 96 44 109 0 # Second item with id=12, price="96", description="44 109" # Return: True # Insert 37 47 109 475 694 88 0 # Another item with id=37, price="47", description="109 475 694 88" # Return: True # DeleteID 37 # Return: 37 47 109 475 694 88(in a single line) # FindID 22 #Return 22 19 475 1238 9742 # PrintTotal # Return: 22+12 = 34 # Insert 22 100 75 128 742 0 # Same item with id=22, not included in the list # Return: False # Insert 45 100 75 128 742 0 # New item with id=45, price="$100", description="75 128 742" # Return: True # PrintTotal # Return: 22+12+45 = 79 # DeleteID 111 #Id=111 is not in the list so print Null # Sadsad #This is an error in line print error message in the output file Insert 9 #This is an error in line print error message in the output file End {Even if there are line after this the program will not read them.} The corresponding out file the above input file True True True 37 47 109 475 694 88 22 19 475 1238 9742 34 False True 79 Null Error Error in Insert Submission Submit the following items through eLearning: ALL JAVA FILES SHOULD BE IN DEFAULT PACKAGE. 1. README.txt This should identify who you are (name, NetID, etc.), which project you are submitting, what files comprise your project, how you developed and compiled your project (e.g. what IDE or text editor, which version of Java, what compiler options, etc.), and any other information you believe the grader should know or you want the grader to know. Please include sample commands that corresponding output. If some methods do not work completely please indicate. 2. MyItem.java 3. IDedObject.java 4. IDedLinkedList.java 5. P2Driver.java All items should be submitted as a single zipped file named with your lowercase NetID. The file structure should resemble the following example: *-- abc123789.zip |-- README.txt |-- IDedObject.java |-- IDedLinkedList.java |-- MyItem.java |-- P2Driver.java Specification Submission import java.io.File; import java.io.PrintWriter; import java.util.*; public class P2Driver { public static void main(String[] args) { Scanner in; if (args.length!=2) { System.out.print("Error Incorrect Arguments:" + Arrays.toString(args)); System.exit(0); } try { File input_file = new File(args[0]); in = new Scanner(input_file); File output_file = new File(args[1]); PrintWriter out; out = new PrintWriter(output_file); IDedLinkedList LL = new IDedLinkedList(); String operation = ""; int lineno = 0; int id, price; boolean result; List name = new LinkedList<>(); whileloop: while (in.hasNext()) { lineno++; operation = in.next(); if(operation.charAt(0) == '#') { in.nextLine(); continue; } switch (operation) { case "End": break whileloop; case "Insert": try { id = in.nextInt(); price = in.nextInt(); name.clear(); while(true) { int val = in.nextInt(); if(val == 0) { break; } else { name.add(val); } } MyItem new_item = new MyItem(id, price, name); result = LL.inserAtFront(new_item); //result = Insert the item into the linkedlist and get true or false out.println(result ? "True" :"False"); } catch (Exception e){ out.println("ERROR"); } break; case "FindID": try { id = in.nextInt(); MyItem item1 = LL.findID(id); //Call the FindID method and printID method to print to the output file the entire item in a line.