Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java - OOP - Linked Lists The purpose of this assignment is to gain experience implementing data structures with linked lists, and sing the type
Java - OOP - Linked Lists
The purpose of this assignment is to gain experience implementing data structures with linked lists, and sing the type system hierarchy and polymorphism to support generalized data structures Abstract Data Type: ist", ke a top-ten list, is a collection of items in a defined order, such that each item has an assigned a A "l position from one to tbc length of the list. Forexample, in the list: Fred, 46, "Wie gehts?", 3 5i, II AT, Barney l the item Fred' is at position one, and the item Barney isat position six. that the items do to be sorted in any way. Note also that lists implicitly do not contain holes the next item after the third is always the fourth. Deleting an item does not leave a hole: for example, after deleting the third item the item that used to be fourth is now third, the fifth is now fourth, and so on. On the other hand, inserting r it after inserting an item at position three, the item that used to be third an item pushes all the items afte is now fourth, the fourth is now fifth, and so on. that could be supported by a list, but for this exercise provide the follo There are many operatio (1) initialize: create an empty list (no items) (2) insert: insert a given item at a given position in the list, insertAtEnd: insert a given item at the end of the list, (4) deleteRange: delete all the items from a given start position to a given end position, a (5) deleteltem: delete all the occurrences of given item from the list retrieve: return the item at a given position in the list (6) (7) find: return a list of the positions where a given item is found in the list (8) getSize: return the number of items in the list, (9) show: return a string summarizing the contents of the list. the how' operation must be named toString The first operation is a constructor, and The first item is at position one. Valid positions extend from one (not zero) to the number ofitemsin the list. (The only exception is for 'insert': the maximum position is the size of the list plus one, so that an item can be inserted on the end.) If an operation is attempted with an invalid position, ignore the operations do not have to The insertion and deletion requested operation, and, if required, return nu return anything. Application write a simple test program to exercise all the operations of a list by maintaining three lists: one with Strings and two with inventory items. An inventory item contains the following information: the lists, inventory item (a the and the cost per item (dollars). Construct three empty allow the user to perform selected operations. Include one option for each ofthe operations listed above, and one more to compute the total value of all items in the lists of inventory (compute the sum of the quantity times the cost for each item). For each operation, let the user select hich list to manipulate, then allow them to choose from a menu of the available operations. For each option, prompt for any necessary input, and display the results of each operation (or a simple message ifthere no result. For the deleteltem and find operations, prompt for the name of the inventory item only (not the other fields. With the find operation, display the entire list of results. Always give the user some feedback to indicate that the program has responded to the reque but don't display the contents of the list unless requested) The purpose of this assignment is to gain experience implementing data structures with linked lists, and sing the type system hierarchy and polymorphism to support generalized data structures Abstract Data Type: ist", ke a top-ten list, is a collection of items in a defined order, such that each item has an assigned a A "l position from one to tbc length of the list. Forexample, in the list: Fred, 46, "Wie gehts?", 3 5i, II AT, Barney l the item Fred' is at position one, and the item Barney isat position six. that the items do to be sorted in any way. Note also that lists implicitly do not contain holes the next item after the third is always the fourth. Deleting an item does not leave a hole: for example, after deleting the third item the item that used to be fourth is now third, the fifth is now fourth, and so on. On the other hand, inserting r it after inserting an item at position three, the item that used to be third an item pushes all the items afte is now fourth, the fourth is now fifth, and so on. that could be supported by a list, but for this exercise provide the follo There are many operatio (1) initialize: create an empty list (no items) (2) insert: insert a given item at a given position in the list, insertAtEnd: insert a given item at the end of the list, (4) deleteRange: delete all the items from a given start position to a given end position, a (5) deleteltem: delete all the occurrences of given item from the list retrieve: return the item at a given position in the list (6) (7) find: return a list of the positions where a given item is found in the list (8) getSize: return the number of items in the list, (9) show: return a string summarizing the contents of the list. the how' operation must be named toString The first operation is a constructor, and The first item is at position one. Valid positions extend from one (not zero) to the number ofitemsin the list. (The only exception is for 'insert': the maximum position is the size of the list plus one, so that an item can be inserted on the end.) If an operation is attempted with an invalid position, ignore the operations do not have to The insertion and deletion requested operation, and, if required, return nu return anything. Application write a simple test program to exercise all the operations of a list by maintaining three lists: one with Strings and two with inventory items. An inventory item contains the following information: the lists, inventory item (a the and the cost per item (dollars). Construct three empty allow the user to perform selected operations. Include one option for each ofthe operations listed above, and one more to compute the total value of all items in the lists of inventory (compute the sum of the quantity times the cost for each item). For each operation, let the user select hich list to manipulate, then allow them to choose from a menu of the available operations. For each option, prompt for any necessary input, and display the results of each operation (or a simple message ifthere no result. For the deleteltem and find operations, prompt for the name of the inventory item only (not the other fields. With the find operation, display the entire list of results. Always give the user some feedback to indicate that the program has responded to the reque but don't display the contents of the list unless requested)Step by Step Solution
There are 3 Steps involved in it
Step: 1
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