Question: in java 6. (40 points) Write the class UniqueArray which represents an array whose values are unique, namely no item appears twice. The class can

in java 6. (40 points) Write the class UniqueArray which represents anin java

6. (40 points) Write the class UniqueArray which represents an array whose values are unique, namely no item appears twice. The class can store only reference values. Upon construction of the class, the user will pass an array which may contain duplicate values. Your goal would be to generate a separate array with no duplicates. Your implementation should maintain the original ordering of elements. In addition, your class will provide the method numofoccur which outputs the number of occurrences of an element at position i. Finally, your class will support the method get which returns the item at position i. See also the example below. You must use the modifiers abstract, final, private, protected, public, and static appropriately. In order to get full credit on this problem, it is not enough that your code merely works. You may lose points if you do not use appropriate modifiers where they clearly belong. The code below shows a partial implementation of the class UniqueArray: public class UniqueArray { private object[] arr; public UniqueArray (Object[] arr); public Object get (int i); public int numofoccur (int i); For example, consider the following code: public class Test { public static void main(String[] args) { Integer[] iarr = {1,2,2,3,3,3,4,4,4,4}; UniqueArray uarr = new UniqueArray ( iarr ); System.out.println("uarr at 3: " + uarr.get (3) + W with #occur: " + uarr.numofoccur (3)); The contents of uarr are {1,2,3,4} and the output in this case is: uarr at 3: 4 with #occur: 4

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!