Question: 2. Considering the following requirements write down a Java program: 30 (1) SpecialNumbers class represents a set of unique integers. Its capacity can be specified

 2. Considering the following requirements write down a Java program: 30(1) SpecialNumbers class represents a set of unique integers. Its capacity can

2. Considering the following requirements write down a Java program: 30 (1) SpecialNumbers class represents a set of unique integers. Its capacity can be specified at the time of creation and cannot be altered subsequently. It maintains the actual length of the set (i.e., the number of the unique integers). It incorporates a method referred to as conditionalAdd that adds the specified new element to the set by following: (i) If the new element is unique in the set, the new element is added and the length of the set is increased. (ii) The sequence of the added numbers is internally maintained. (iii) It throws an IllegalState Exception if the new element to be added is already present or the set has already attained its maximum capacity. (2) The getLength() method tells how many elements are present. (3) The getCapacity() method tells how many elements in total can be stored. (4) The nth method returns the n-th value after arranging all the elements in ascending (increasing) order. If n = 1, it returns the lowest number. If n = 2, it returns the second lowest number. If n = 3, it returns the third lowest number, etc. If n = length, it returns the highest number. The method corrects any out-of-boundary values of n to be as the boundary values. That is, if n length, it returns the highest number. (5) In order to support a subsequence of the numbers, the following new constructor and method are added to the SpecialNumbers class. (a) The new constructor creates a SpecialNumbers with the specified int array as numbers. (b) The subNumbers method creates a SpecialNumbers containing a subsequence of this SpecialNumbers. Arguments start and end specify the first and last characters, respectively, in the subsequence. If start and/or end are out-of-range values, the values are adjusted following the nth method convention. An IllegalArgumentException is thrown if start is greater than end after the adjustment. The functions of Java's built in Arrays class and methods you can use in your program: // Create a copy with mentioned quantity of elements from beginning int[] temp = Arrays.copyOf(numbers, length)

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!