// This is lab test #5 version 1 // You are to add three new methods to the List class, found on the G: drive. // Information on the methods to add can be found below. // Note that the first two methods can be iterative or recursive. The third one (worth // 5 bonus marks) must be recursive. // Your methods must work under all circumstances (feel free to add more test cases). // Submit files List.h and List.cpp. // // Note that this lab is worth a total of 15 (5 marks for each method), // but we will pretend that it's out of 10, i.e. you can get a maximum of 150%! #include "stdstuff.h" #include "List.h" int main () { List list, list2, list3, list4; int i; for (i = 0; i < 15; i++) { list.insert ((i * i) - (8 * i) + 2); } list2.insert(5); list3=list; list4=list; list.outputList (); // Method "sumMoreThan" returns the sum of the values in the list that are more than // the given value (here 8). If the list contains no values more than the given value, it returns 0. // You are to add this method to class "List" (see above). // Note that your method should work properly in all circumstances, not just for this // particular list and value. Your method can be iterative or recursive. cout << "\nthe sum of values more than 8 is: " << list.sumMoreThan(8)<< "\n\n"; // Method "duplicateEvens" duplicates every even value in the list. Note that "even" refers // to the contents of the node, not its position in the list. // If the list contains no even values, the method has no effect, i.e. the list is unchanged. // This method *never* quits! // You are to add this method to class "List" (see above). // Note that your method should work properly in all circumstances, not just for this // particular list. Your method can be iterative or recursive. list.duplicateEvens(); cout << "after duplicating every even value the list is:\n"; list.outputList (); // Method "isShorterThan" returns true if the first (implicit) lists is shorter than // (i.e. has fewer values than) the other (explicit) list. Otherwise it returns false // (i.e. the first list is longer than or equal to the other list). // You are to add this method to class "List" (see above). // Note that your method should work properly in all circumstances, not just for these // particular lists. Your method must be recursive. if(list2.isShorterThan(list4)) cout << "\nCORRECT: list2 is shorter than list4.\n"; else cout << "\nINCORRECT: list2 is not shorter than list4.\n"; if(list4.isShorterThan(list3)) cout << "\nINCORRECT: list4 is shorter than list3.\n"; else cout << "\nCORRECT: list4 is not shorter than list3.\n"; pause(); return 0; }