Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 below):

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 below):

image text in transcribed

Private data: - nligs, - ncols, - matrix: two-dimensional array of integers representing the matrix. 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 toString() method that replaces (override) the toString method in the Object class and prints the contents of the matrix. 4 - A showMatrix() method which displays the contents of the matrix in a window using a jLabel for each element. (see execution example below). An example of a test program of this class is given below:

public static void main(String[] args) { int m1[][]={{1,2,3}, { 4,5,6}, {7,8,9}}; // essai du constructeur aleatoire Matrice F0= new Matrice(10,10); System.out.println("F0= "+F0); // essai d'affichage F0.showMatrix(); // essai de la transposition Matrice F1= new Matrice(m1); System.out.println("F1= "+F1); F1.transpose(); System.out.println("F1 aprs transposition= " + F1); // essai de flip left right Matrice F2=new Matrice(m1); System.out.println("F2= " + F2); Matrice F3= Matrice.flipLeftRight(F2); System.out.println("F3= flip Left Right de F2 " + F3); // essai de la rotation Matrice F4= Matrice.rotateClockwise(F2); System.out.println("F5= rotation clockwise de F2 " + F4);

image text in transcribed

Matrice -nligs: int -ncols: int -matrice[]]: int +Matrice(matrice[]]: int) +Matrice(nligs: int, ncols: 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 +toString(): String \begin{tabular}{|llllllllllll} \hline Matrice F0 & & & & & & & & \\ 89 & 67 & 20 & 11 & 21 & 39 & 33 & 46 & 87 & 63 \\ 100 & 69 & 99 & 69 & 70 & 32 & 35 & 25 & 39 & 8 \\ 66 & 100 & 56 & 97 & 38 & 97 & 64 & 99 & 14 & 11 \\ 62 & 36 & 32 & 37 & 19 & 11 & 100 & 90 & 38 & 55 \\ 97 & 4 & 79 & 0 & 96 & 10 & 99 & 90 & 92 & 64 \\ 91 & 14 & 96 & 86 & 40 & 72 & 69 & 38 & 85 & 14 \\ 34 & 48 & 50 & 39 & 45 & 60 & 87 & 20 & 18 & 94 \\ 36 & 93 & 51 & 80 & 91 & 2 & 100 & 12 & 68 & 56 \\ 89 & 75 & 95 & 75 & 30 & 87 & 36 & 13 & 56 & 18 \\ 12 & 90 & 78 & 21 & 49 & 0 & 21 & 35 & 91 & 17 \\ \hline \end{tabular} Figure 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

Psychologists must practice within the boundaries of competence.

Answered: 1 week ago