Question: Question 2: Class Matrix (11 pts) using java We are asked to design a Class called Matrix to perform some operations elementary matrices with integer-valued

Question 2: Class Matrix (11 pts) using java We are asked to design a Class called Matrix to perform some operations elementary matrices with integer-valued square matrices. The class contains (see UML  Figure 1): Private data: oh nligs, o ncols, o matrix: two-dimensional array of integers representing the matrix. Public constants: o ALONGLINES: integer constant which equals 0. o ACCORDING: integer constant which equals 1.

Question 2: Class Matrix (11 pts) using java We are asked to

Two builders: - The first initializes a matrix of dimensions nligs by ncols with integers random between 0 and 100 inclusive. - The second constructs a matrix from a two-dimensional array of integers. Public methods: - Accessors for private data: nligs, ncols - A method getValueAt(int i, int j) which returns the value of the element (i,j) of the matrix. - A method setValueAt(int i, int j, int newValue) which modifies the value of the element (i,j) of the matrix. - A method transpose() which performs the transposition of the matrix on which was made the call. - A static method flipLeftRight(Matrix A) which returns a Matrix type object which is the permutation of the matrix A around its vertical center (see execution example below) below). - A static method rotateClockwise(Matrix A) which returns a Matrix type object which is the rotation of the matrix A clockwise (rotation 90 degrees). - A static method concatenate(Matrix A, Matrix B, int direction) which returns a Matrix type object which is the concatenation of matrices A and B as follows: a) If direction=Matrix.ALONGLINES, the concatenation is done in the form [A B] b) If direction=Matrix.ACCORDINGCOLUMNS, the concatenation is done in the form [ AT B ] In a) the result matrix has a number of rows equal to the greatest number of rows between A and B. Missing row elements will be filled with zero in the result matrix.

design a Class called Matrix to perform some operations elementary matrices with

In b) the result matrix has a number of columns equal to the greatest number of columns between A and B. Missing column elements will be filled with zero in matrix results. - A toString() method that replaces (override) the toString method in the Object class and prints the contents of the matrix. An example of a test program of this class is given below, the result can be found on the next page, Figure 2(a). Bonus (+2 points): Modify your program to work with matrices rectangular (not necessarily square); see Figure 2(b);

integer-valued square matrices. The class contains (see UML Figure 1): Private data:

Matrice -nligs: int -ncols: int -matrice[][]: int +SELONLIGNES: int +SELONCOLONNES : int +Matrice(nligs: int, ncols: int) +Matrice(matrice[][]: int) +getnligs(): int +getncols(): int +getValueAt(i: int, j:int): int +setValueAt(i: int, j: int, newValue: int) +transpose() + flipleftRight(A: matrice): Matrice +rotateClockwise(A: matrice): Matrice +concatenate(A: matrice, B: Matrice, direction: int): Matrice +toString(): String

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!