Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Specification The project must implement the following specification exactly, which includes identifier names, method signatures, etc. For this project, you will be writing one
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 Myltem 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: void makeEmpty(); AnyType findID(int ID); //empties the linked list // 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); AnyType deleteFromFront(); AnyType delete(int ID); int printTotal(); i. FindID // insert at front of list or return false if that ID already exists // delete and return the record at the front of the list or return null if the list is empty In addition to the above methods, you must have a constructor and may have other private methods. // find and delete the record with the given ID or returns null if it isn't found 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 Myltem objects. The main class can handle the following operations by calling the appropriate methods of IDedLinkedList. v. PrintTotal // return the sum of ids of all elements currently in the list. if list is empty return -1. vi. End 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. /// print all details of the item with given ID in a single line, if it is in the list, if not print Null iv. DeletelD /// Print the details of the particular IDed item and then delete it.. If list is empty or item not found, print Null. /// Print sum of all item ids in the list, the linkedlist should handle this method. ///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. 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 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. Myltem.java 3. IDedObject.java 4. IDedLinked List.java 5. P2Driver.java
Step by Step Solution
★★★★★
3.44 Rating (160 Votes )
There are 3 Steps involved in it
Step: 1
Below is the code for the above problem IDedLinkedListjava import javautilLinkedList IdedLinkedList contains generic type of elements public class IDedLinkedList private LinkedList list default constr...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