Question: to be completed in Java. please answer numbers 7 and 8. attached are images of the class which must be modified as per the attached

to be completed in Java. please answer numbers 7

to be completed in Java. please answer numbers 7 and 8. attached are images of the class which must be modified as per the attached

to be completed in Java. please answer numbers 7

instructions

to be completed in Java. please answer numbers 7

THERE IS NO MISSING INFORMATION. the images show the depicted class which must be modified as per the instructions in the image. answer numbers 4, 5, and 6.

 to be completed in Java. please answer numbers 7 and 8.

opioaded and printed materials due In this assignment you will get practice working with the book's (p. 586) Arraylist implementation. You will amend the basic ArrayList class provided in the weiss.util package. All existing functionality must be preserved unless explicitty specified otherwisel Remember that ArrayList is generic. Implement the Java class depicted below, using your own code. You may not use API's ArrayList class or any other API collection save arrays. Be sure specs exactly. Please keep with the spirit of the assignment or risk a significant penalty to follow the ou will revise the Weiss ArrayList class with the following modifications (Note that from this point onward substitute "Whatever" with your class 1) The list must be sorted in ascending order at all times, with no null references in the name- details below); middle of the data. The list must have this order maintained at the end of every public method call, so some existing methods will need to be modified. 2) Modify the add () (and any other methods as you see fit) method of the class so that each new item is inserted in sorted (ascending) order 3) Overload add () with signature specified below. This method inserts the item at the specified index, adjusting incumbent items as needed. Note that if the index parameter is not the proper one for that item based on ordering the method should insert the item at the proper index that places it in order, not the requested one. public void add (int index, AnyType element 4) Modify the set () method so that it replaces and returns the item at the specified index. Observe and adjust for any issues due to the requested index and order as specified for the overloaded add () method in 3) 5) Adjust the constructor that takes a Collection parameter so that it creates the er with the same size as the Collection passed to it. The constructor still initializes the whatever with the contents of the Collection parameter. 6) Add another constructor that takes in a lone integer parameter. The Whatever is initially created to this size rather than the default size. 7) Add an instance method named getMode() that returns the most-occurring value in the list. The method's return type is Result, a generic interface that has two methods: AnyType mode (), which returns the most-occurring item in the list, and int count (), which returns how many times that item occurs. Tiebreak on first- occurring item of the highest frequency. The code for the Result interface will be provided to you to incorporate into your package. Do not send this interface file with your code the values necessary to support the interface methods. It does not include any computation logic - all work should be done by your list class . Note that the object you return needs to be a very simple container with 8) Add a generic static method that takes in a (your) Whatever and performs a binary search on it. The method takes exactly two parameters: a Whatever, and the item to search for. The type of the second parameter needs to reflect what coul possibly be in the Whatever instance. This method returns an int that is the index in the list where the item resides, or-1 if not found. The method header will look similar (same name but you need to revise it to make it use generics) to: public st atic int binSearch (Whatever list, AnyType item) 586 inner classes and implementation of ArrayList chapter 15 1 package weiss.util; 2 figure 15.13 Arraylist implementation part 1) public class ArrayListanyType> extendentbstractCollectionAnyTypo 6 private static final int DEFAULT CAPACITY 10; implements List 7 private static final int NOT FOUND 9 private AnyType [ theItems; -1; 10 private int theSize; 11 private int modCount 0; public ArrayList() 13 14 15 t clear); 16 public Arraylist( Collection extends AnyType> other ) 18 19 20 21 clear(); for( AnyType obj: other) add( obj ); 23 public int size ) 24 return theSize; 25 26 public void clear) theSize 0; theItems - (AnyType []) new Object[ DEFAULT CAPACITY J: modCount++ 29 31 33 public AnyType get( int idx) if( idx = size( ) ) 35 36 37 38 39 throw new ArrayIndex0ut0fBoundsException(); return theltems[ idx 1: 40 public AnyType set( int idx, AnyType newVal ) 41 42 43 if( idx - size()) throw new ArrayIndexoutOfBoundsException ): AnyType old theItems[ idx ]; theItems[ idx] newval; 45 46 47 return old; 49 50 10 10 public boolean contains( Object x) t return findPos(x) ! NOT_FOUND; 15.5 implementation of ArrayList with an iterator s2 private int findPos( Object x ) figure 15.14 for( int i-0; i other) clear( ); for( AnyType obj: other) 67 68 69 70 18 20 add( obj ); 72 73 74 75 76 23 public int size) 24 f return theSize; 26 public void clear ) 27 28 29 theSize 0; theltems(AnyType []) new Object [ DEFAULT-CAPACITY ]; modCount++ 78 79 80 31 32 33 public AnyType get( int idx ) 84 34 35 36 37 38 if( idx - size) ) throw new ArrayIndex0utOfBoundsException(): return theltems[ idx l; 87 90 40 public AnyType set( int idx, AnyType newVal) if( idx -size( ) ) throw new ArrayIndexOutofBoundsException(): AnyType old theItems [ idx ]; theltens[ idx ] = newval; 92 93 94 95 96 97 98 43 45 47 return old; 49 50 51 public boolean contains( Object x) { return findPos( x ) != NOT-FOUND; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!