Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is data structure i need solution please in java lang 1- Create a generic class MyList that has An array of generic type (elements),

this is data structure i need solution please in java lang image text in transcribed
1- Create a generic class MyList that has An array of generic type (elements), and an integer count that indicates how many elements currently in the array. 2- Add the following a. Non-parameter constructor that creates the array with default size 10 elements. b- Parameter constructor that creates the array with the size that input as a parameter. C. Method size() that returns how many elements currently in the array. d- Method add(Te), void method that adds elemente to the end of the array if it is not full, otherwise it throws an exception. e-Method addinti, Te), void method that shifts the elements and inserts elemente at the position if the array is not full , otherwise it throws an exception. f. Method clear(), which is void method that removes all elements from the array. g. Method get(int i) which returns the element at position i, if there is no element at that position, it throws an exception. h- Method set(int i T e) which is a void method that replaces element at position i by elemente, if there is no position, it throws an exception. i- Method remove (int i), it removes the element at position i and return that element. It shifts the other elements. - Method indexOf( T e), it searches for the elemente, it retums its index if found, otherwise it retums - 1. k- Method getAll(which returns an array of current elements in the array. 3- Create a class Student that has: Id fint), name(String), GPA (double). a. Add a parameter constructor that initialize the three properties. b. Add setter/getter methods. c. Add toString method. 4- Create a class Test that has main method, create and object of MyList, and objects of Student to test the methods in the class MyList. 5. Modify methods add questions d, e), so incase the array is full, it create a new array with double size as the original, copy the elements to the new one, make elements reference the new one, and add the new element. 6- Test methods add after modification) in the main. 7- Add method trim ToSize(): that trim the size of the array to number of elements currently in the array (by creating a new array with size equal to number of elements, copy these elements to the new array and make elements reference the new array). 8- Test method trim ToSize in the main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions