Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Important: All submissions will be passed though software for plagiarism check, and violations will be required to be reported as an obligation. In this project,

image text in transcribed
image text in transcribed
image text in transcribed
Important: All submissions will be passed though software for plagiarism check, and violations will be required to be reported as an obligation. In this project, you will be developing a class to represent an RC matrix and provide basic matrix operations such as add//subtract and multiply operations with file output. Learning Objectives The focus of this assignment is on the following leaming objectives: - Be able to develop classes that allocate/deallocate dynamic memory properly. - Be able to work with two-dimensional afrays. - Be able to implement copy constructors. copy-assignment, and destructors correctly. - Be able to work with file l/O Problem Description You are to implemess a Maris class to represent a RC matrix. The Matix should provide the following functionalities: 1. Construction: the class should provide a default constructor, and a parametrized constructor that accepts the dimensions of the matrix with a name identification string and copy constructor to altow corred conseructing of a class object from an exisxing object. Consiructos shoald set the dimensions properly and create a two-dimensional array (RC) with a name identification (sering) to hold the Matrix elemenes. Display all manrix abjects created using tie function mentioned in step 2 below, Also send all matrices created to an output file called results.osv. Before sending the results to the results.cst file, make sure you label the follonsing rable with iss asme identification and insest a blank line in the filte after inserting the matrix uble. 2. A display function to display the matrix object with its nume identification. 3. Testing the copy assignment use the copy assignment on two previously created objects and divilay the results of copy assignment locally by divplaying the results and sending the changed matix to the results.cs file. Make sure you label the followieg macix table with its aume identification before the table and insen a blank line in the tile afuer inserting the matrix table. 4. Destruction: the class should have a destructor to fre the memory that was allocated by the construcoors. Make sare that you tes your program for any memory leaks using the tools such as volgrind discusved in class and giver as arsignments io test with the sample. programs in the previous week. 5. The matrix addition operation: the addition fusction of the matrix accepts a Matrix object as a parameter (constait reference), adds the currest Matrix and returns the result as a Matrix object. The add function sboold check for matching dimensions of the matrices. if the matrices do not mutch in dimensions, the result slould be a Matrix object with dimensions equal to those of the current matrix initialized with all zeros. This result is sepposed to be displayed locally (on the monitor, in the output area) as well as written to an outpait file called results.csv. Before saving the rewils to the results.ost file, make sure you Label the reselts as "After Matrix Addition operation" and insert a blank line in the file affer inserting the resalts of addition. 6. The matrix subtraction operation: the suberactice function of the marrix like the add operation. The resalt of subtractice is supposed to be displayed locally (on the monifor, in the output area) as well as written to the cuppil fle called resultsosv. Before sming the results to the results.csv file, make sure you label the rewalts as "After Matrix Subtraction operation" and inser a blank, line in the file atter inserting the results of subtraction. 7. The matrix multiplication operations the matrix mulliplication function accepts a Matrix object as a parameter (constant reference). multiplies the current Matrix by the parameter and retums the result as a Matrix object. Like the add function, the multiply function should check for appropriate dimensions of the matrices. If the matrices do not have appropriate dimensions for mukiplication, the result should be a matix with dimensions equal to itose of the currem matrix initalibed with all zeros, The result of multiplication is ropposed to be displayed locally (oe the nsoeitor, in the cupot arev) as well as wrimen oo the output fille called resultuosv. Before saving the results to the results.ov file, muke sure you label the resalts as "After Matrix Multiplication operation" and insert a blank line in the fille after iesserting the cesults of multiplication. 8. You also need to peovide the appeopriaee setters and getters. Test Program: - Develop a test program (main.cpp) that will test all functionalities of the Matrix class. For example, you need to test constructing objects in various ways: default, parametrized, copy construction and copy assignment. Further, you need to test object creation and assignment to other objects using all possible ways mentioned. - You can think about implementing a menu for your tests. Some hints on menu options for these tests and possible test scenario: - Default constructor - assames M=3 and N=3, creates a 33 matrix called matrix 1 - Parametrized Constructor - creates MxN matrix2 as per user specification of M,N and the values that are to be stored in matrix2. The user can similarly create matrix3 and matrix 4. - Copy constructor - When this mena option is chosen, asks user which matrix to copy into the new matrix to be created, then copies one of matrix1 - matrix 4 (as specified by the user) to create a new matrix5 - Copy Assignment operator - When this menu option is chosen, asks user which matrix to copy into another matrix already created, then copies one of matrix1 matrixs (as specified by the user) to create a new matrix 6 - Add matrices - a function that lets the user specify two matrices to add, adds them and sends the output to an output file results.csv, If an addition is not possible due to a mismatch in matrix dimensions, display an error and return to the menu. - Subtract a matrix from another - a function that lets the user specify two matrices a and b, subtracts matrix b from matrix a, and sends the output to append to the output file results.csv. If a subtraction is not possible due to a mismatch in matrix dimensions, display an error and return to the menu, - Multiply a matrix to another - a function that lets the user specify two matrices a and b, multiplies matrix a to matrix b and sends the output to append to the output file results.csv. If multiplication is not possible due to a mismatch in matrix dimensions, display an error and return to the menu - Exit - exits the ment and ends the program - You also need to test all the matrix operations provided with appropriate dimensions and with inappropriate dimensions (for example with 0 or negative values and unmatched values for the operations). You can assume that the biggest matrix we will test your code with will not exceed 1212, but do not hardcode your project with this assumption. - You should also prepare a makefile to compile and run your program. You should also test run your code using this makefile on the UWF SSH server of the virtual machine prior to submission. Development Diary For this project, you must complete the following tasks in the order that they are described: 1. Write down the list of all classes/operations that you need to implement. Write down the member variables and the member functions that you need to implement. 2. Create a plan to implement your solution to the problem with a timeline. Each step in your plan refers to an increment of the program that you will be creating. It is recommended to complete the implementation of a single logical action per step. Your responses to these tasks should be submitted as a PDF document called lastname_firstname_project04.pdf. Grading Breakdown - [15 pts] Full-coverage test driver. Driver should call all functionality and print out the result of each operation. This test driver should print the result and save the values in the file as specified. - [10pts] proper implementation of the multiply function - [5 pts] proper implementation of the add function - [5 pts] proper implementation of the subtract function - [10 pts] proper implementation of the file storage - [15 pts] proper implantation of the constructors including copy constructor - [15 pts] Proper implantation of the copy assignment operator - [10 pts] proper implantation of the destructor - [10 pts] Clear, easy-to-read code (e.g. class declarations in .h files, class definitions in .cpp files, working makefile, etc.) - [5 pts] Development "diary" (report) that details design and implementation of each class, as well as the project as a whole. Should include a reflection of the process as a whole upon completion of the project (identify the challenges, lessons learned, ways to improve in the future, etc.) - Bonus: 15 extra points will be awarded for implementing operator overloading for the +,, and operators ( 5 points each) to provide the Matrix functionality using these operators. Important: All submissions will be passed though software for plagiarism check, and violations will be required to be reported as an obligation. In this project, you will be developing a class to represent an RC matrix and provide basic matrix operations such as add//subtract and multiply operations with file output. Learning Objectives The focus of this assignment is on the following leaming objectives: - Be able to develop classes that allocate/deallocate dynamic memory properly. - Be able to work with two-dimensional afrays. - Be able to implement copy constructors. copy-assignment, and destructors correctly. - Be able to work with file l/O Problem Description You are to implemess a Maris class to represent a RC matrix. The Matix should provide the following functionalities: 1. Construction: the class should provide a default constructor, and a parametrized constructor that accepts the dimensions of the matrix with a name identification string and copy constructor to altow corred conseructing of a class object from an exisxing object. Consiructos shoald set the dimensions properly and create a two-dimensional array (RC) with a name identification (sering) to hold the Matrix elemenes. Display all manrix abjects created using tie function mentioned in step 2 below, Also send all matrices created to an output file called results.osv. Before sending the results to the results.cst file, make sure you label the follonsing rable with iss asme identification and insest a blank line in the filte after inserting the matrix uble. 2. A display function to display the matrix object with its nume identification. 3. Testing the copy assignment use the copy assignment on two previously created objects and divilay the results of copy assignment locally by divplaying the results and sending the changed matix to the results.cs file. Make sure you label the followieg macix table with its aume identification before the table and insen a blank line in the tile afuer inserting the matrix table. 4. Destruction: the class should have a destructor to fre the memory that was allocated by the construcoors. Make sare that you tes your program for any memory leaks using the tools such as volgrind discusved in class and giver as arsignments io test with the sample. programs in the previous week. 5. The matrix addition operation: the addition fusction of the matrix accepts a Matrix object as a parameter (constait reference), adds the currest Matrix and returns the result as a Matrix object. The add function sboold check for matching dimensions of the matrices. if the matrices do not mutch in dimensions, the result slould be a Matrix object with dimensions equal to those of the current matrix initialized with all zeros. This result is sepposed to be displayed locally (on the monitor, in the output area) as well as written to an outpait file called results.csv. Before saving the rewils to the results.ost file, make sure you Label the reselts as "After Matrix Addition operation" and insert a blank line in the file affer inserting the resalts of addition. 6. The matrix subtraction operation: the suberactice function of the marrix like the add operation. The resalt of subtractice is supposed to be displayed locally (on the monifor, in the output area) as well as written to the cuppil fle called resultsosv. Before sming the results to the results.csv file, make sure you label the rewalts as "After Matrix Subtraction operation" and inser a blank, line in the file atter inserting the results of subtraction. 7. The matrix multiplication operations the matrix mulliplication function accepts a Matrix object as a parameter (constant reference). multiplies the current Matrix by the parameter and retums the result as a Matrix object. Like the add function, the multiply function should check for appropriate dimensions of the matrices. If the matrices do not have appropriate dimensions for mukiplication, the result should be a matix with dimensions equal to itose of the currem matrix initalibed with all zeros, The result of multiplication is ropposed to be displayed locally (oe the nsoeitor, in the cupot arev) as well as wrimen oo the output fille called resultuosv. Before saving the results to the results.ov file, muke sure you label the resalts as "After Matrix Multiplication operation" and insert a blank line in the fille after iesserting the cesults of multiplication. 8. You also need to peovide the appeopriaee setters and getters. Test Program: - Develop a test program (main.cpp) that will test all functionalities of the Matrix class. For example, you need to test constructing objects in various ways: default, parametrized, copy construction and copy assignment. Further, you need to test object creation and assignment to other objects using all possible ways mentioned. - You can think about implementing a menu for your tests. Some hints on menu options for these tests and possible test scenario: - Default constructor - assames M=3 and N=3, creates a 33 matrix called matrix 1 - Parametrized Constructor - creates MxN matrix2 as per user specification of M,N and the values that are to be stored in matrix2. The user can similarly create matrix3 and matrix 4. - Copy constructor - When this mena option is chosen, asks user which matrix to copy into the new matrix to be created, then copies one of matrix1 - matrix 4 (as specified by the user) to create a new matrix5 - Copy Assignment operator - When this menu option is chosen, asks user which matrix to copy into another matrix already created, then copies one of matrix1 matrixs (as specified by the user) to create a new matrix 6 - Add matrices - a function that lets the user specify two matrices to add, adds them and sends the output to an output file results.csv, If an addition is not possible due to a mismatch in matrix dimensions, display an error and return to the menu. - Subtract a matrix from another - a function that lets the user specify two matrices a and b, subtracts matrix b from matrix a, and sends the output to append to the output file results.csv. If a subtraction is not possible due to a mismatch in matrix dimensions, display an error and return to the menu, - Multiply a matrix to another - a function that lets the user specify two matrices a and b, multiplies matrix a to matrix b and sends the output to append to the output file results.csv. If multiplication is not possible due to a mismatch in matrix dimensions, display an error and return to the menu - Exit - exits the ment and ends the program - You also need to test all the matrix operations provided with appropriate dimensions and with inappropriate dimensions (for example with 0 or negative values and unmatched values for the operations). You can assume that the biggest matrix we will test your code with will not exceed 1212, but do not hardcode your project with this assumption. - You should also prepare a makefile to compile and run your program. You should also test run your code using this makefile on the UWF SSH server of the virtual machine prior to submission. Development Diary For this project, you must complete the following tasks in the order that they are described: 1. Write down the list of all classes/operations that you need to implement. Write down the member variables and the member functions that you need to implement. 2. Create a plan to implement your solution to the problem with a timeline. Each step in your plan refers to an increment of the program that you will be creating. It is recommended to complete the implementation of a single logical action per step. Your responses to these tasks should be submitted as a PDF document called lastname_firstname_project04.pdf. Grading Breakdown - [15 pts] Full-coverage test driver. Driver should call all functionality and print out the result of each operation. This test driver should print the result and save the values in the file as specified. - [10pts] proper implementation of the multiply function - [5 pts] proper implementation of the add function - [5 pts] proper implementation of the subtract function - [10 pts] proper implementation of the file storage - [15 pts] proper implantation of the constructors including copy constructor - [15 pts] Proper implantation of the copy assignment operator - [10 pts] proper implantation of the destructor - [10 pts] Clear, easy-to-read code (e.g. class declarations in .h files, class definitions in .cpp files, working makefile, etc.) - [5 pts] Development "diary" (report) that details design and implementation of each class, as well as the project as a whole. Should include a reflection of the process as a whole upon completion of the project (identify the challenges, lessons learned, ways to improve in the future, etc.) - Bonus: 15 extra points will be awarded for implementing operator overloading for the +,, and operators ( 5 points each) to provide the Matrix functionality using these operators

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_2

Step: 3

blur-text-image_3

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

Cost Accounting Principles And Applications

Authors: Horace R. Brock

5th Edition

0070081522, 978-0070081529

More Books

Students also viewed these Accounting questions

Question

What sorting algorithm doesvthe gollowing code represents Java

Answered: 1 week ago