Question: Java. use scanner use test JUnit4 just answer question 5 to question 9 Thank you so much Instructions: Review the requirements given below and Complete

 Java. use scanner use test JUnit4 just answer question 5 toquestion 9 Thank you so much Instructions: Review the requirements given belowand Complete your work. Please compress all files (including main to testyour work) into a zip file and submit it through Canvas. Do

Java.

use scanner

use test JUnit4

just answer question 5 to question 9

Thank you so much

Instructions: Review the requirements given below and Complete your work. Please compress all files (including main to test your work) into a zip file and submit it through Canvas. Do not include any binary files. The grading scheme is provided on Canvas Ask questions during the Lab hours to understand more. Objectives: (100 points: 15+25+60) What you will learn: Array (One Dimensional and 2 Dimensional) and ArrayList Writing class Unit Testing 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 isEqual (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 ( 4 0 7 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. T / 5 4 4 0 7 10 5 4 7 -1 4 0 10 8 -1 2X4 8 1. 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 rotateClockwise() { } 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. 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 isEqual (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 0, 0, 0 0, 0, 0], my Matrix.toString()); Instructions: Review the requirements given below and Complete your work. Please compress all files (including main to test your work) into a zip file and submit it through Canvas. Do not include any binary files. The grading scheme is provided on Canvas Ask questions during the Lab hours to understand more. Objectives: (100 points: 15+25+60) What you will learn: Array (One Dimensional and 2 Dimensional) and ArrayList Writing class Unit Testing 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 isEqual (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 ( 4 0 7 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. T / 5 4 4 0 7 10 5 4 7 -1 4 0 10 8 -1 2X4 8 1. 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 rotateClockwise() { } 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. 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 isEqual (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 0, 0, 0 0, 0, 0], my Matrix.toString())

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!