From 73403fb967eaa8ac2e6d26417cfeeab3904fa76e Mon Sep 17 00:00:00 2001 From: James Knee Date: Tue, 19 Nov 2024 21:16:40 -0500 Subject: [PATCH 1/3] bug fixes --- problems/LabFour_ChapterEleven.h | 2 +- tests/LabFour.cpp | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/problems/LabFour_ChapterEleven.h b/problems/LabFour_ChapterEleven.h index 7098140..75429cb 100644 --- a/problems/LabFour_ChapterEleven.h +++ b/problems/LabFour_ChapterEleven.h @@ -42,7 +42,7 @@ int labFour_pTwo_exchange(int dollars); * @param nn The term in the sequence that is desired, with nn=0 being * the first term. * @return the [nn]th number in a Generalized Fibonacci sequence with - * filter [filter]. + * filter [filter]. Rounded to 4 decimal places. * * @example 1 * labFour_pThree_genFib({1,1},n) produces the n+4-th Fibonacci numbers: diff --git a/tests/LabFour.cpp b/tests/LabFour.cpp index 3ef2222..b910871 100644 --- a/tests/LabFour.cpp +++ b/tests/LabFour.cpp @@ -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(); @@ -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; } @@ -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; } -- GitLab From bf1b59f3ae5b77ebec85d58fe78c4357f3782353 Mon Sep 17 00:00:00 2001 From: James Knee Date: Tue, 19 Nov 2024 22:19:09 -0500 Subject: [PATCH 2/3] updated changes --- problems/LabFour_ChapterEleven.h | 2 +- tests/LabFour.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/problems/LabFour_ChapterEleven.h b/problems/LabFour_ChapterEleven.h index 75429cb..7098140 100644 --- a/problems/LabFour_ChapterEleven.h +++ b/problems/LabFour_ChapterEleven.h @@ -42,7 +42,7 @@ int labFour_pTwo_exchange(int dollars); * @param nn The term in the sequence that is desired, with nn=0 being * the first term. * @return the [nn]th number in a Generalized Fibonacci sequence with - * filter [filter]. Rounded to 4 decimal places. + * filter [filter]. * * @example 1 * labFour_pThree_genFib({1,1},n) produces the n+4-th Fibonacci numbers: diff --git a/tests/LabFour.cpp b/tests/LabFour.cpp index b910871..66bc043 100644 --- a/tests/LabFour.cpp +++ b/tests/LabFour.cpp @@ -208,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; } -- GitLab From c196fdbf9767d579de9a3fbee4533235286a07e5 Mon Sep 17 00:00:00 2001 From: James Knee Date: Wed, 20 Nov 2024 13:33:06 -0500 Subject: [PATCH 3/3] missing pointer in definition --- problems/LabFour_ChapterTen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/problems/LabFour_ChapterTen.h b/problems/LabFour_ChapterTen.h index a76811e..08c44f5 100644 --- a/problems/LabFour_ChapterTen.h +++ b/problems/LabFour_ChapterTen.h @@ -81,13 +81,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 things); + static float sumAreas(vector 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 things); + static float sumPerimeters(vector things); }; class labFour_pOne_Quadrilateral : public labFour_pOne_GeometricThing { -- GitLab