Question: Prepare a project in Java to implement two classes: MyApp and MyList. a) for the class MyList: The class MyList is a class to represent
Prepare a project in Java to implement two classes: MyApp and MyList. a) for the class MyList: The class MyList is a class to represent resizable arrays of integers. Each MyList instance has a capacity. The capacity is the size of the array used to store the elements in the list. The capacity is always at least as large as the list size. As elements are added to an object of the class MyList, its capacity grows automatically. The initial capacity, if not specified, is 100 elements. If necessary, increase the capacity to 120% of the size of the list. On the other hand, if necessary, reduce the capacity to accommodate less elements. The initial value of the elements is 0. - private attributes (member-variables): Attribute: array Description: array to store the elements of the list. Attribute: numberOfElements Description: number of elements stored in the list. Attribute: isSorted Description: flag to indicate if the list is sorted. - public constructors: MyList( ) MyList(int numberOfElements) MyList(MyList myList) - public methods (member-functions) Method: clone Description: creates and returns a copy of this object. Method: copy Description: makes this object equal to another object of this class. Method: equals Description: indicates whether this object is equal to another object of this class. Method: toString Description: returns a string representation of the object. Method: add Description: appends an element to the end of the list. Method: clear Description: removes all elements from the list. Method: contains Description: indicates whether the list contains the specified element. Method: fill Description: fill the list with the specified element. Method: fillRange Description: fill the specified range of the list with the specified element. Method: get Description: gets the element at the specified position in the list. Method: indexOf Description: returns the index of the first occurrence of the element in the list; or -1 if the list does not contain the element. Method: insert Description: inserts an element at the specified position in the list. Method: isEmpty Description: indicates whether the list is empty. Method: isSorted Description: indicates whether the list is sorted. Method: lastIndexOf Description: returns the index of the last occurrence of the element in the list; or -1 if the list does not contain the element. Method: remove Description: removes the first occurrence of the element in the list. Method: removeAt Description: removes the element at the specified position in the list. Method: removeFirst Description: removes the first element in the list. Method: removeLast Description: removes the last element in the list. Method: removeAll Description: removes all occurrences of the specified element from the list. Method: removeRange Description: remove all elements, whose index is in the specified range, from the list. Method: set Description: sets the element at the specified position in the list. Method: showElements Description: prints all elements of the list. Method: size Description: returns the number of elements in the list. Method: sort Description: sorts the elements of the list using Merge Sort Algorithm. Method: sublist Description: creates and returns a sublist of this list, with the elements in the specified range. Method: toArray Description: creates and returns an array with the elements of the list in the same order. Remark: you need to identify the input parameters and the return type for each method. b) for the class MyApp: - method main: instantiate objects of the class MyList using all constructors; use all methods of the class MyList; and show the elements of the list after changing the list.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
