// This is version 1 of lab test #3 for lab section D1 with TA tests added. // You are to add two new methods to the List class, found on the G: drive. // Information on the methods to add can be found below. // Submit files List.h and List.cpp using the submit program provided. #include "stdstuff.h" #include "List.h" void realMain () { List list, list2, list3, list4, list5; for (int i = 0; i < 15; i++) { list.insert ((i * i) - (8 * i) + 3); } list3.insert(3); list4.insert(4); list5.insert(3); list5.insert(2); list5.insert(6); list5.insert(9); // Method "countOddValues" returns the number of nodes in the list containing odd values. // Note that "containing" refers to the *contents* of the node, not its position in the list. // If the list contains no odd values, it returns 0. // You are to add this method to class "List". // Note that your method should work properly in all circumstances, not just for this // particular list. (Feel free to add additional test cases.) cout << "\nThe number of odd values in list is (should be 8): " << list.countOddValues() << "\n\n"; cout << "\nThe number of odd values in list2 is (should be 0): " << list2.countOddValues() << "\n\n"; cout << "\nThe number of odd values in list3 is (should be 1): " << list3.countOddValues() << "\n\n"; cout << "\nThe number of odd values in list4 is (should be 0): " << list4.countOddValues() << "\n\n"; cout << "\nThe number of odd values in list5 is (should be 2): " << list5.countOddValues() << "\n\n"; // Method "deleteValuesMultThree" deletes every node containing // a value that is an exact multiple of 3 (i.e. ..., -9, -6, -3, 0, 3, 6, ...). // If the list contains no values that are multiples of 3, it has no effect. // You are to add this method to class "List". // Note that your method should work properly in all circumstances, not just for this // particular list. (Feel free to add additional test cases.) list.deleteValuesMultThree(); list2.deleteValuesMultThree(); list3.deleteValuesMultThree(); list4.deleteValuesMultThree(); list5.deleteValuesMultThree(); cout << "After deleting the list values that are multiples of three\n (should be: 68 23 -4 -13 -4):\n"; list.outputList (); cout << "\n"; cout << "After deleting the list2 values that are multiples of three\n (should be: empty):\n"; list2.outputList (); cout << "\n"; cout << "After deleting the list3 values that are multiples of three\n (should be: empty):\n"; list3.outputList (); cout << "\n"; cout << "After deleting the list4 values that are multiples of three\n (should be: 4):\n"; list4.outputList (); cout << "\n"; cout << "After deleting the list5 values that are multiples of three\n (should be: 2):\n"; list5.outputList (); cout << "\n"; } int main () { try { realMain (); } catch (exception &e) { cout << "Exception occurred " << e.what() << endl; } pause(); return 0; }