Question: I need some help with the two other classes i have been working on. The test class does not to be modified but matrix3d.hpp and

I need some help with the two other classes i have been working on. The test class does not to be modified but matrix3d.hpp and .cpp do. Right now I'm just trying to get the matrix to work, and I would love to know what I did wrong and how to correct them

here is test-3-matrix3d.cpp

#include "catch/catch.hpp"

#include "../matrix3d.hpp"

TEST_CASE ("Default Matrix")

{

Matrix3D m;

CHECK(0 == m.GetValue(0, 0));

}

TEST_CASE ("Specified Matrix")

{

/*

1 0 2

1 2 0

1 0 0

*/

Matrix3D m(1,0,2, 1,2,0, 1,0,0);

CHECK(1 == m.GetValue(0, 0));

CHECK(2 == m.GetValue(0, 2));

}

TEST_CASE ("Determinant for default matrix")

{

Matrix3D m;

CHECK(0 == m.Determinant());

}

TEST_CASE ("Determinant for specified matrix")

{

Matrix3D m(1,0,2, 1,2,0, 1,0,0);

CHECK(-4 == m.Determinant());

}

matrix3d.hpp

#ifndef MATRIX3D_HPP

#define MATRIX3D_HPP

class Matrix3D

{

private:

const static int r =3;

const static int c =3;

int i =0;

int j =0;

public:

Matrix3D(int arr[r][c]);

int GetValue(int arr[r][c]);

int Determinant();

};

#endif

matrix3d.cpp

#include "matrix3d.hpp"

Matrix3D::Matrix3D(int arr[r][c])

{

for(int i=0; i< r;i++)

{

for(int j=0; j< c; j++)

{

arr[r][c] = arr[i][j];

}

}

}

int Matrix3D::GetValue(int arr[r][c])

{

this-> i =i;

this-> j=j;

return this-> arr[i][j];

}

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!