Question: Description: Create an immutable datatype called Matrix. It represents an m x n matrix ( a matrix with m rows and n columns) Implement class

Description: Create an immutable datatype called Matrix. It represents an m x n matrix ( a matrix with m rows and n columns)  Description: Create an immutable datatype called Matrix. It represents an m Implement class Matrix as specified in the UML class diagram. Notice the three overloaded constructors:

Matrix (m : int, n : int) creates an m x n matrix and fills it with random floating point numbers

Matix ( data : double[][] ) creates a matrix based on the data provided in the two-dimensional array Make sure to copy the data provided as argument to ensure immutability

Matrix ( matrix : Matrix ) This constructor is a copy constructor. A copy constructor is a constructor that creates and initializes a new object from existing object (instance) of the same type. In order to avoid code repetition, this constructor should be implemented by calling the overloaded constructor, that accepts an array as an argument.

For a refresher on how to add and subtract matrices, you can check out http://www.purplemath.com/modules/mtrxadd.htm (Links to an external site.)Links to an external site. (Links to an external site.)Links to an external site. Remember that the class Matrix is immutable. When we add or subtract we return the result but the matrix remains unchanged.

The method print should print the matrix elements in a tabular form. All numbers should be rounded to 2 decimal places. Choose a column width so that all numbers less than one thousand are displayed well. (see output)

Matrix - m int n int data double J] Matrix (m int, n: int) +Matrix ( data doubleII) + Matrix ( matrix : Matrix) +plus (other Matrix) Matrix + minus (other : Matrix) Matrix + print ()

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!