Commit 369c91c9 authored by Ari Trachtenberg's avatar Ari Trachtenberg
Browse files

Merge branch 'lab4bugFixes' into 'master'

bug fixes

See merge request !12
parents 7dc1f5f9 c196fdbf
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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 {
+21 −12
Original line number Diff line number Diff line
@@ -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;
    }
@@ -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;
    }