subject

We will be creating a class which will be given a 2-D array when instantiated, and then implement various methods to perform operations on the 2-D array. Create the class with the following API. Then write main program to test all methods of your class. public class Matrix { private boolean[][] matrix; private final int NUMROW: private final int NUMCOL; public Matrix(boolean[][] m) { } public String toString() {} public Matrix transposeMatrix() {} public boolean is Square Matrix() { } public Matrix rotateClockwise() { } public Matrix rotate CounterClockwise() { } public String percentage True() { } public boolean is Equal (Matrix m) {} 1. public Matrix(boolean[][] m) { } a. Initialize the NUMROW and NUMCOL variables. These are the row and column dimensions of m. b. The constructor should initialize the boolean[][] matrix. c. Do not assume the input to the constructor is a NxN matrix The constructor and other methods need to work on matrices that have any column and row sizes. Methods should work on 4x4s, 4x2s, 7x5s, etc. 2. public String toString() { } a. returns a string value of the entire matrix. To receive full points, string must be in this form: Each value should have a comma and a space except the last one. There should be no space before the closing bracket. True is 1, false is 0. 4x4 matrix [1, 1, 1, 1 0,1,0,1 0,1, 1, 1 1, 1, 0, 1] 2x4 matrix [0,1,1,1 1, 1, 0, 1] 3. public Matrix transposeMatrix() {} a. Returns the transpose of the instance field matrix as a new Matrix object b. Include these two matrices below in your test cases for this method. The transpose of a matrix is a new matrix whose rows are the columns of the original. (This makes the columns of the new matrix the rows of the original). Here is a matrix and its transpose: 1 5 4 7 4 0 10 3 4 3 = 15 4 3 4 0 4 7 10 3 Another way to look at the transpose is that the element at row r column c in the original is placed at row c column r of the transpose. The element arc of the original matrix becomes element acr in the transposed matrix. 15 4 IT 4 0 7 10 1- 18 5 4 7 4 0 10 -1 8 4x2 4x4 matrix (1,1,1,1 0, 1, 0,1 0, 1, 1,1 1, 1, 0, 1] It should return the following as output: 4x4 matrix (1, 0, 0,1 1, 1, 1,1 1,0, 1,0 1, 1, 1, 1] 4. public boolean is Square Matrix() { }a. returns true if the instance field matrix is a square matrix i. e., NUMROW is equal to NUMCOL; otherwise returns false 5. public Matrix rotate Clockwise() { } a. Returns the instance field matrix rotated 90° to the right Example: [ 1, 1, 1, 1 1, 1, 0,0 1, 1, 1, 1] [1, 1, 1 1, 1, 1 1,0,1 1,0, 1] 6. public Matrix rotate CounterClockwise() { } a. Returns the instance field matrix rotated 90° to the left. Example: [ – 1,1,1 1,1,1 1,0,1 1,0, 1] (1, 1, 1, 1 1,1,0,0 1, 1, 1, 1] 7. public String percentage True() { } a. Returns the percentage of indices that are true in the instance field matrix. b. For simplicity, always round up to the nearest whole percentage. Example: [ + "50%" 1, 1, 1, 1 0,0,0,0 0,0,0,0 1, 1, 1, 1] 8. boolean is Equal (Matrix m) a. returns true if the instance field matrix is equal to given matrix m. The matrices will be equal if they have the same number of rows and columns and every value is also equal; otherwise return false 9. As always, use the main as a test client to test each function. Write JUnit tests for all methods. Note: where line breaks are added in your toString() method, they will need to be added in Junit tests as well. For example, below is a unit test of calling toString() on a 3x3 matrix with all false indices: assertEquals("[0, 0, 0\n 0, 0, 0\n 0,0,0)", my Matrix. toString());

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:00
Which of the following is true of operations within a spreadsheet program’s built-in functions? a. operations within parentheses, then multiplication and division, and then addition and subtraction are computed. b. operations within parentheses, then addition and subtraction, and then multiplication and division are computed. c. multiplication and division, then addition and subtraction, and then operations within parentheses are computed. d. addition and subtraction, then multiplication and division, and then operations within parentheses are computed
Answers: 2
question
Computers and Technology, 22.06.2019 15:20
The north and south regions had very diferent economies in the 1800s.
Answers: 1
question
Computers and Technology, 22.06.2019 16:30
Primary tech skills are skills that are necessary for success in online education
Answers: 3
question
Computers and Technology, 23.06.2019 01:10
Problem 1 - hashing we would like to use initials to locate an individual. for instance, mel should locate the person mark e. lehr. note: this is all upper case. generate a hash function for the above using the numbers on your telephone. you know, each letter has a number associated with it, so examine your telephone keypad. generate 512 random 3 letter initials and take statistics on a linked list array size 512 to hold this information report how many have no elements, 1 element, 2 elements, does this agree with the hashing statistics distribution?
Answers: 1
You know the right answer?
We will be creating a class which will be given a 2-D array when instantiated, and then implement va...
Questions
question
Mathematics, 17.07.2019 23:20
Questions on the website: 13722359