This week's project is a team project to add more functionality to the Matrix class we built in this week's lab. To illustrate, suppose that m1, m2, and m3 are Matrix objects containing the following values:
m1 == {1, 2, 3, 4, 5, 6}
m2 == {2, 3, 4, 5, 6, 7}
m3 == {0, 0, 0, 0, 0, 0}
m1 != m2should return true. The expression:
m1 != m1should return false.
m.readFrom(cin);or
m.readFrom(fin);should read m.getRows() * m.getColumns() values from cin or fin. In other words, this method should assume that the Matrix to which this message has been sent has already been constructed with the correct size. The test-method for this operation uses the file MatrixTest1.txt, so be sure to import it into your project.
m.writeTo(cout);or
m.writeTo(fout);should write the values of m to cout or fout, neatly organized in rows and columns, with columns separated by tabs.
m.readFrom(fileName);should fill m with values stored in fileName. You may assume that the first line of fileName has two integers that specify the number of rows and columns of the data in the file.
m.writeTo(fileName);should write all of the values in m to the file named by fileName, neatly organized into rows and columns, with columns separated by tabs. The first line of fileName should consist of the number of rows and columns in m.
m3 = m1 + m2;should set
m3 == {3, 5, 7, 9, 11, 13}For Matrix addition to be defined, the two matrices being summed must have the same number of rows and the same number of columns, but the number of rows need not equal the number of columns.
m3 = m2 - m1;should set
m3 == {1, 1, 1, 1, 1, 1}For Matrix subtraction to be defined, the two matrices being summed must have the same number of rows and the same number of columns, but the number of rows need not equal the number of columns.
m3 = m1.getTranpose();should set
m3 == {1, 4, 2, 5, 3, 6}More generally, the m.getTranpose() operation should return a Matrix whose columns are m's rows, and whose rows are m's columns.
As indicated on the grade sheet, different members of your team are responsible for different operations. See me for the teams for this project.
As usual, the opening documentation in each file should indicate who wrote which methods.
To make life easier for you, MatrixTester contains a test-method for each of these operations. Use these test-methods and test driven development to build your operations. If you get your program to compile, but it fails a test and you cannot figure out what is wrong, use the debugger! If necessary, draw a memory diagram and trace through the execution of the problematic function one statement at a time, until you identify the logic error.
Template. When you have "finished" your Matrix class, convert it to a Matrix<Item> template and modify the tests in MatrixTester to test your new template.
Application. When you have "finished" your Matrix<Item> template, write a program that:
Create a script file in which you use ls to list all your project's files, use cat to display the contents of each file, and build+run your project to demonstrate that it works correctly. Make certain that your script file is located in your project folder.
Our grader will grade your submission based on the categories given in this grade sheet, so you should make certain all of those categories are covered.