Question
Implement the above UML diagram in Java. As a instance variable, there is a 2d array called array2d. In the constructor(2 points), get the row
Implement the above UML diagram in Java. As a instance variable, there is a 2d array called "array2d". In the constructor(2 points), get the row and column number, initialize the array accordingly. Using the fillArray method(2 points), add random elements to this 2d array (use 0-10 range). The getColumn method(3 points), returns a 1d array back containing the elements of the given column in array2d in the same order as they appear in this array2d. Make sure that the given column is valid for array2d. isEquivalent method(8 points) returns true only if every value in first array(first argument for this method) appears in the second array (second argument for this method). hasDuplicates method(5 points) returns true if there are any duplicate values in the given array, false otherwise. isPerfect method (10 points) returns true if array2d is a perfect array. A 2d array is perfect if: the first row has no duplicates all the first row elements also appear in each row of this array too all the first row elements also appear in each column of this array too Make sure that the given 2d array has equal number of rows and columns and has at least one row Example: int [][] array2d = { {1,2,3}, {4,5,6}, {7,8,9}} array2d.getColumn(2) should return {2,5,8} Examples of perfect array: { {1,2,3},{2,3,1},{3,1,2} } { {10,20,30,40},{40,30,20,10},{30,40,10,20} ,{20,10,40,30}} Examples of non-perfect array: { {1,2,1},{2,1,1},{1,1,2} } { {1,2},{1,2} } { {1,2,3},{3,1,2},{4,5,6} }
FinalExam array2d: int[10 + FinalExam(int,int) fillArray(int[0) : void + getColumn(int[]0),int): int[] + is Equivalent(int[], int(l): boolean + hasDuplicates(int[]): boolean + isPerfect(int[0]): booleanStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started