Loading problems/LabFour_ChapterTen.h +2 −2 Original line number Diff line number Diff line Loading @@ -93,13 +93,13 @@ public: * @param things A vector of geometric things whose areas are to be summed. * @return The sum of the areas of all geometric things in the vector [things]. */ static float sumAreas(vector<labFour_pOne_GeometricThing> things); static float sumAreas(vector<labFour_pOne_GeometricThing *> things); /** * @param things A vector of geometric things whose areas are to be summed. * @return The sum of the areas of all geometric things in the vector [things]. */ static float sumPerimeters(vector<labFour_pOne_GeometricThing> things); static float sumPerimeters(vector<labFour_pOne_GeometricThing *> things); }; class labFour_pOne_Quadrilateral : public labFour_pOne_GeometricThing { Loading tests/LabFour.cpp +21 −12 Original line number Diff line number Diff line Loading @@ -37,15 +37,15 @@ bool test_labFour_pZero(){ input1 >> person5; input2 >> person6; Common::redirIO(); Common::redirIO(""); cout << person4; string output0 = Common::restoreIO(); Common::redirIO(); Common::redirIO(""); cout << person5; string output1 = Common::restoreIO(); Common::redirIO(); Common::redirIO(""); cout << person6; string output2 = Common::restoreIO(); Loading Loading @@ -155,7 +155,8 @@ bool test_labFour_pOne(){ return false; } if(rh1.getArea() != sqrt(2) / 2){ float area0 = sqrt(2) / 2.0; if(rh1.getArea() != area0){ cout << "Test 1g failed" << endl; return false; } Loading @@ -165,23 +166,26 @@ bool test_labFour_pOne(){ return false; } if(c1.getArea() != M_PI){ float area1 = M_PI; if(c1.getArea() != area1){ cout << "Test 1i failed" << endl; return false; } if(c1.getPerimeter() != 2 * M_PI){ float perimeter0 = 2 * M_PI; if(c1.getPerimeter() != perimeter0){ cout << "Test 1j failed" << endl; return false; } if(labFour_pOne_GeometricThing::sumAreas(things) != 1 + 2 + 9 + sqrt(2) / 2 + M_PI){ float sumAreas0 = 1 + 2 + 9 + sqrt(2) / 2.0 + M_PI; if(labFour_pOne_GeometricThing::sumAreas(things) != sumAreas0){ cout << "Test 1k failed" << endl; return false; } if(labFour_pOne_GeometricThing::sumPerimeters(things) != 4 + 6 + 12 + 4 + 2 * M_PI){ float sumAreas1 = 4 + 6 + 12 + 4 + 2 * M_PI; if(labFour_pOne_GeometricThing::sumPerimeters(things) != sumAreas1){ cout << "Test 1l failed" << endl; return false; } Loading @@ -204,17 +208,22 @@ bool test_labFour_pTwo(){ bool test_labFour_pThree(){ if(labFour_pThree_genFib({1,1}, 3) != 8){ float fib0 = labFour_pThree_genFib({1,1}, 3); float fib1 = labFour_pThree_genFib({1,0,1}, 4); float fib2 = labFour_pThree_genFib({0.25 ,0.25 ,0.5, 0.5}, 3); if((fib0 >= 7.99) && (fib0 <= 8.01)){ cout << "Test 3a failed" << endl; return false; } if(labFour_pThree_genFib({1,0,1}, 4) != 9){ if((fib1 >= 8.99) && (fib1 <= 9.01)){ cout << "Test 3b failed" << endl; return false; } if(labFour_pThree_genFib({0.25 ,0.25 ,0.5, 0.5}, 3) != 2.5625){ if( (fib2 >= 2.562) && (fib2 <= 2.563)){ cout << "Test 3c failed" << endl; return false; } Loading Loading
problems/LabFour_ChapterTen.h +2 −2 Original line number Diff line number Diff line Loading @@ -93,13 +93,13 @@ public: * @param things A vector of geometric things whose areas are to be summed. * @return The sum of the areas of all geometric things in the vector [things]. */ static float sumAreas(vector<labFour_pOne_GeometricThing> things); static float sumAreas(vector<labFour_pOne_GeometricThing *> things); /** * @param things A vector of geometric things whose areas are to be summed. * @return The sum of the areas of all geometric things in the vector [things]. */ static float sumPerimeters(vector<labFour_pOne_GeometricThing> things); static float sumPerimeters(vector<labFour_pOne_GeometricThing *> things); }; class labFour_pOne_Quadrilateral : public labFour_pOne_GeometricThing { Loading
tests/LabFour.cpp +21 −12 Original line number Diff line number Diff line Loading @@ -37,15 +37,15 @@ bool test_labFour_pZero(){ input1 >> person5; input2 >> person6; Common::redirIO(); Common::redirIO(""); cout << person4; string output0 = Common::restoreIO(); Common::redirIO(); Common::redirIO(""); cout << person5; string output1 = Common::restoreIO(); Common::redirIO(); Common::redirIO(""); cout << person6; string output2 = Common::restoreIO(); Loading Loading @@ -155,7 +155,8 @@ bool test_labFour_pOne(){ return false; } if(rh1.getArea() != sqrt(2) / 2){ float area0 = sqrt(2) / 2.0; if(rh1.getArea() != area0){ cout << "Test 1g failed" << endl; return false; } Loading @@ -165,23 +166,26 @@ bool test_labFour_pOne(){ return false; } if(c1.getArea() != M_PI){ float area1 = M_PI; if(c1.getArea() != area1){ cout << "Test 1i failed" << endl; return false; } if(c1.getPerimeter() != 2 * M_PI){ float perimeter0 = 2 * M_PI; if(c1.getPerimeter() != perimeter0){ cout << "Test 1j failed" << endl; return false; } if(labFour_pOne_GeometricThing::sumAreas(things) != 1 + 2 + 9 + sqrt(2) / 2 + M_PI){ float sumAreas0 = 1 + 2 + 9 + sqrt(2) / 2.0 + M_PI; if(labFour_pOne_GeometricThing::sumAreas(things) != sumAreas0){ cout << "Test 1k failed" << endl; return false; } if(labFour_pOne_GeometricThing::sumPerimeters(things) != 4 + 6 + 12 + 4 + 2 * M_PI){ float sumAreas1 = 4 + 6 + 12 + 4 + 2 * M_PI; if(labFour_pOne_GeometricThing::sumPerimeters(things) != sumAreas1){ cout << "Test 1l failed" << endl; return false; } Loading @@ -204,17 +208,22 @@ bool test_labFour_pTwo(){ bool test_labFour_pThree(){ if(labFour_pThree_genFib({1,1}, 3) != 8){ float fib0 = labFour_pThree_genFib({1,1}, 3); float fib1 = labFour_pThree_genFib({1,0,1}, 4); float fib2 = labFour_pThree_genFib({0.25 ,0.25 ,0.5, 0.5}, 3); if((fib0 >= 7.99) && (fib0 <= 8.01)){ cout << "Test 3a failed" << endl; return false; } if(labFour_pThree_genFib({1,0,1}, 4) != 9){ if((fib1 >= 8.99) && (fib1 <= 9.01)){ cout << "Test 3b failed" << endl; return false; } if(labFour_pThree_genFib({0.25 ,0.25 ,0.5, 0.5}, 3) != 2.5625){ if( (fib2 >= 2.562) && (fib2 <= 2.563)){ cout << "Test 3c failed" << endl; return false; } Loading