Question
Create a list class implemented using an array named ListArray that provides the following methods: ListArray() Constructs a list using an array with 10 elements.
Create a list class implemented using an array named ListArray that provides the following methods:
ListArray() | Constructs a list using an array with 10 elements. |
ListArray( int capacity ) | Constructs a list using an array with capacity elements. |
void add( E item ) | Add item to the list |
int find( E target ) | Find target in the list If found, return the index (relative 0) If not found, return -1 Note: The find() method should use equals() method to compare generic objects as done by the Java ArrayList class. |
E get( int index ) | Return object E at position index in list If index out of bounds, return null |
Thoroughly test all of the methods with a simple test class before using the array list to complete the assignment. Once the ListArray class has been successfully tested, proceed with developing the application below.
Develop a client program Prog2.java that maintains a list of parts. The program should begin by reading the parts.txt file, creating Part object, and storing the Part objects in a ListArray data structure.
parts.txt file: CSV (comma separated value) text file in which each line in the file represents parts in a warehouse. The comma delimited fields are:
Fields | Description |
Part Number | 5 characters |
Description | maximum 30 characters |
Price | double |
Warehouse ID | 3 characters |
Quantity | Integer, quantity at this warehouse |
After the ListArray data structure is filled, print a report listing the parts in an easy to read tabular format. Then, ask the user for a part number and display the part information using the find() and get() methods of the ListArray
csv file
12345,Left-Handed Bacon Stretcher,125.95,PGH,2 24680,Smoke Shifter,0.98,PGH,48 86420, Pre-dug Post Hole,2.49,ATL,34 25632,Acme Widget,98.29,LOU,342 97531,Anti-Gravity Turbine,895.29,ATL,3 24680,Battery-Powered Battery Charger,252.98,ATL,2 12345,Left-Handed Bacon Stretcher,125.95,LOU,35 97531,Anti-Gravity Turbine,895.29,PHL,8 00000,Glass Hammer,105.90,PGH,8 01020,Inflatable Dartboard,32.95,PGH,453 86420, Pre-dug Post Hole, 2.49,LOU,68 86420, Pre-dug Post Hole, 2.49,PGH,124 24680, Battery-Powered Battery Charger, 252.98, PHL, 5
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