Question: Create a Generic class called KeysUtility ( 3 5 points ) . The UML class diagram is in the FinalExamFiles folder. The class has the
Create a Generic class called KeysUtility points
The UML class diagram is in the FinalExamFiles folder.
The class has the following specifications:
It should have the following instance variable:
alist:java.util.ArrayList
bkey:int
crandom:java.util.Random
It should have the following constructors:
a A noargs default constructor that creates an ArrayList object of default capacity and assigns its reference to the instance variable list. Creates a Random object by calling the default constructor and assigns its reference to the instance variable random. Generates a random integer in the range both inclusive and assigns it to the instance variable key.
b A constructor with one argument int key that creates an ArrayList object of default capacity and assigns its reference to the instance variable list. Assigns the integer argument to the instance variable key.
It should have the accessor getters and mutator setters methods for the instance variable key.
It should have a toString method that returns the instance variables list and as a String.
It should have a method addKeyToListo:E:void that adds the object o to the ArrayList referenced by the instance variable list.
It should have a method removeKeyFromEndOfList:E If the ArrayList referenced by the instance variable list is not empty, the method removes the object at the end of the ArrayList and returns it Otherwise, the method returns null.
It should have a method: reverseKeysListlist:java.util.ArrayList:java.util.ArrayList that reverses the ArrayList that is passed to it The ArrayList must be reversed as follows:
i Remove the elements one by one from the front of the ArrayList passed as parameter to the method and add them to the ArrayList referenced by the instance variable list using the method addKeyToListo:E:void until the ArrayList passed as parameter to the method is empty
ii Remove the elements one by one from the end from the ArrayList referenced by the instance variable list using the method removeKeyFromEndOfList:E and add them to the ArrayList passed as parameter until the ArrayList referenced by the instance variable list is empty
iii. Return the ArrayList passed as parameter to the method
Create a class called TestKeysUtility points
The class has the following specifications:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
