Question: LinkedListBox (JAVA PROGRAM) Patterned after the ArrayBox assignment, please create your own implementation of LinkedList called LinkedListBox as explained in class. Refer to the class
LinkedListBox (JAVA PROGRAM)
Patterned after the ArrayBox assignment, please create your own implementation of LinkedList
public class LinkedListNode
Within the LinkedListBox class, implement the following methods:
public boolean add(E e). Returns true after adding an element to the end of the list.
public E get(int idx). Returns element at index position idx.
public E set(int idx, E e). Changes the element at position idx to e. Returns old element.
public E remove(int idx). Removes element at position idx from the list and returns it.
public int size(). Self-explanatory
public boolean isEmpty(). Self-explanatory
public Integer find(E e). Search for element e in the linked list and return its index position or return null if not found.
public E removeFirst(). Remove and return the element at the head of the list.
public E removeLast(). Remove and return the element at the tail of the list.
public void addFirst(E e). Add an element to the front of the list.
public void insert(int idx, E e). Insert an element right after the index idx position.
Create a driver class called LinkedListBoxDriver. Provide the user a menu:
=[==[==[=[=================================]=]==]==]= =[==[==[=[ Welcome to LinkBox ]=]==]==]= =[==[==[=[=================================]=]==]==]= Choose... 1. Add an element(String) to our box. 2. Remove an element(String) from our box. 3. Replace(set) an element(String) from our box. 4. Insert an element(String) after index. 5. List the contents of the box. 6. Exit program
Deliverables
Archive(ZIP) your program (if necessary) and upload it to quiz question #1. Quiz questions Q2-Q8 are for marking purposes only.
Grading Criteria
Q2: Check to see if LinkedListNode and LinkedListBox classes are present and defined as generic. Check to see if all method functions are created as per specification above. 0.5 mark per method. 0.25 mark deduction per method missing an Exception.
Q3: 1. Add an element(String) to our box. Insert 6 items. Then display the list. 1.5 marks if linked list correctly displays all six elements. Part marks otherwise.
Q4: 2. Remove an element(String) from our box. Start with at least 6 elements in the list then:
- Remove the head element (index 0). Give 1 marks if element correctly removed. Part marks for reasonable attempt.
- Remove the last element. Give 1 marks if element correctly removed. Part marks for reasonable attempt.
- Remove an element from the middle of the list (index 1). Give 1.5 marks if element correctly removed. Part marks for reasonable attempt.
Q5: 3. Replace(set) an element(String) from our box. One (1) marks given if you can change an element from somewhere in the middle of the list (not head or tail). Part marks for reasonable attempt.
Q6: 4. Insert an element(String) after index. Give 1.5 marks if you can insert an element in-between two middle elements. Example: insert at index 1 will put the element in-between element 1 and the current element 2. Part marks for reasonable attempt.
Q7: 5. List the contents of the box. 0.5 mark
Q8: A testing script showing a trial run of the program with expected outputs for your testing.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
