Your linked list from exercise 2 should be extended and put on a more professional basis.
Modify your class LinkedListBase from exercise 2 according to the following specifications.
Add an insert method that corresponds to the method remove.
Modify your class LinkedListBase to use exceptions. Implement a professional testbed for the linked list.
Use of exceptions:
For the class LinkedListBase, declare and use the following exceptions in the methods LinkedListBase, append, removeFirst, removeLast, remove, get, insert:
LLBListException extends Exception
LLBListFullException extends LLBListException
LLBListEmptyException extends LLBListException
LLBListIndexOutOFBoundsException extends LLBListException
LLBListTooSmallException extends LLBListException
You should be as specific as possible when using exceptions.
Testbed:
In the class LinkedListBase, implement private test methods for all the private methods. These test methods are called by the method main within the class LinkedListBase.
In the class LinkedListBaseMain, implement test methods for the public methods of LinkedListBase: LinkedListBase, append, find, remove, insert, isConsistent. These test methods are called by the method main within the class LinkedListBaseMain. Remember, testing isConsistent() requires you to create broken lists so that the method can be shown to work.
Each test method tests the appropriate method of class LinkedListBase. Each test method causes all exceptions of the tested method to be thrown which are then caught with an appropriate message using System.out.println. Every case that can occur should be tested, for example, list empty, one element in list, two or more elements in list, etc.
Tips:
Your test program should produce easy-to-read output, but the output does not have to be automatically checked to see if there are errors in your program. For example, my solution to this exercise displays for the method append of LinkedListBase the following:
testAppend
1 2 3 expected
1 2 3
LLBListFullException expected
LLBListFullException thrown