In the packageh10find a generic onepublic-ClassMyLinkedListand a generic onepublic-ClassListItemas in chapter 07, slides 116 ff.
Withobjects,integer,doubles,Number,thongandexception are the classes from Packagejava.langmeant; WithPredicate,BiPredicate andfunctionthe generic classes from Packagejava.util.function.
H1: Exception class for MyLinkedList 2 points
Write a public-ClassMyLinkedListException, directly from exception is derived.
the public-Constructor of MyLinkedListExceptionhas a parameter of formal type integer and a formal type parameter
objects. Without checking, it assumes that both current parameter values are notzero
are, and initializes the message of the exception as "(i,x)", whereby ithe one encapsulated by the first actual parameter
internal-value and xthe return of toString applied to the second parameter.
H2: list methods 28 points
H2.1: Decompose lists 14 points
Expand the classMyLinkedList<T>by two generic public-Object methods extractIterativelyand extractRecursively.
Both methods each have a generic type parameter u, a parameter predT of the formal typepred-
cate<? great T>, a second parameter FCTof the formal typeFunction<? great T,? extends U> and a third parameter predUof the formal typePredicate<? great U>. Return type of both methods isMyLinkedList<U>. Both methods assume, without verification, that none of the three current parameter values are equalzerois. Both methods potentially throw a formal-type exceptionMyLinkedListException.
Expand the classMyLinkedList<T>also a generic oneprivate-Object methodextractRecursivelyHelper. The method has, in addition to the parameters ofextractRecursivelyone more parameterpSrcof the formal type
ListItem<T>and a parameterindexof the typeinternal. Return type of the method is alsoMyLinkedList<U>and it also potentially becomes a formal-type exceptionMyLinkedListExceptionthrown. This helper method is used to test the actual functionality ofextractRecursivelyto implement.
The following is the list to whichthis.headreferences as thesource list, and the list returned as thetarget list designated. Both lists can also be empty, that is, the casesotherList.head ==zeroandthis.head ==zeroare not excluded1, but it won'tzeroreturned. Either method removes allListItem<T>-Objects from the source list for whose key value the functional method ofpredT the valuetrue
delivers. For each of these so distantListItem<T>-Objects becomes aListItem<U>-Object added to the target list. The key value of the latter object is the result of the functional method ofFCTapplied to the key value of the former object. The method does not make any further changes to the source list, and the target list contains no additional elements for either method.
The order ofListItem<U>-Objects in the target list is exactly the order in which their associatedListItem<T>- Objects in the original source list (i.e. in the source list at the beginning of the call toextract*) was.
An exception is thrown if the functional method ofpredUfor a key value to be inserted into the target list, the value falsereturns. The second actual parameter of the constructor call for this exception is this key value. The first actual parameter is the index of the associatedListItem<T>-object in the source list - but not the index in the current source list, from which potentially alreadyListItem<T>objects were extracted, but the index at which it was at the beginning of the call toextract*was. (As usual, is0the index of the first list element.)
1It will follow implicitly from the further text: If the source list is empty, the target list is also empty in any case.
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of