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 (35 points).
The UML class diagram is in the FinalExamFiles folder.
The class has the following specifications:
1) It should have the following instance variable:
a.list:java.util.ArrayList
b.key:int
c.random:java.util.Random
2) It should have the following constructors:
a. A no-args (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 099999(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.
3) It should have the accessor (getters) and mutator (setters) methods for the instance variable key.
4) It should have a toString() method that returns the instance variables list and as a String.
5) It should have a method +addKeyToList(o:E):void that adds the object (o) to the ArrayList referenced by the instance variable list.
6) 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.
7) It should have a method: +reverseKeysList(list: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 +addKeyToList(o: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 (10 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 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 Programming Questions!