|
CSIS 250 2001 Fall Assignment 06 Date Assigned: 11/07/2001 Date Due: 11/16/2001 (detailed algorithm is due on 11/12/2001) Add the following member function to the program discussed in the class: bool CInventory::isEqualToDupesRemoved(const CInventory &inv); As discussed in the class, the member function removeDupes deletes duplicate records from an inventory object. The next step is to check if this function really works. For a given inventory collection originalInv, and an inventory object distinctInv which is made of only distinct records from originalInv, develop the isEqualToDupesRemoved member function for CInventory class. If the original inventory object name is originalInv and the inventory object distinctInv is made of only distinct records from originalInv, then the function call originalInv.isEqualToDupesRemoved(distinctInv) will return true if the distinctInv has only distinct records from originalInv, otherwise it will return false. In order to achieve this it will perform the following tests to checks if the given inventory (distinctInv) has all the distinct records of another inventory (originalInv): test1. count of originalInv should be >= the count of distinctInv test2. distinctInv should not have duplicate records test3. for every record in originalInv there must be only one matching record in distinctInv test4. for every record in distinctInv there must one or more matching records in originalInv test5. total of occurrences of matching records for each record from distinctInv in originalInv should be equal to the total records in originalInv.
Your function should also display if the above five tests were failed or passed by your function. You should run ten test cases (two subcases in each test case case) to test your function by using the following test function as it is: //++++++++++++++++++++++++++++++++++++++++++++++++++ // testIsEqualToDupesRemoved(void); //++++++++++++++++++++++++++++++++++++++++++++++++++ void testIsEqualToDupesRemoved(void) { for (int i=1; i<=10; i++) { { cout << "===================================\n"; cout << "Test Case#:" << i << endl; cout << "===================================\n";
CInventory originalInv('r'); CInventory distinctInv(originalInv);
cout << "originalInv =\n"; cout << originalInv << endl;
distinctInv.removeDupes();
cout << "distinctInv=\n"; cout << distinctInv;
if (originalInv.isEqualToDupesRemoved(distinctInv)) cout << "distinctInv has only distinct records\n"; else cout << "distinctInv does not have distinct records\n"; }
{ CInventory originalInv('r'); CInventory distinctInv('r');
cout << "\noriginalInv =\n"; cout << originalInv << endl;
cout << "distinctInv=\n"; cout << distinctInv;
if (originalInv.isEqualToDupesRemoved(distinctInv)) cout << "distinctInv has only distinct records\n"; else cout << "distinctInv does not have distinct records\n";
}
cout << "-----------------------------------\n"; } }
SAMPLE OUTPUT FROM A TEST RUN=================================== Test Case#:9 =================================== originalInv = inventory(10)= [Phone, 55] [Spoon, 33] [Couch, 66] [Spoon, 33] [Phone, 55] [Stool, 16] [Table, 22] [Phone, 55] [Mouse, 88] [Stand, 15]
distinctInv= inventory(7)= [Phone, 55] [Spoon, 33] [Couch, 66] [Stool, 16] [Table, 22] [Mouse, 88] [Stand, 15] test1: passed test2: passed test3: passed test4: passed test5: passed distinctInv has only distinct records
originalInv = inventory(14)= [Knife, 44] [Spoon, 33] [Plier, 13] [Cable, 12] [Drive, 77] [Mouse, 88] [Spoon, 33] [Spoon, 33] [Stand, 15] [Stand, 15] [Drive, 77] [Spoon, 33] [Mouse, 88] [Paper, 14]
distinctInv= inventory(1)= [Spoon, 33] test1: passed test2: passed test3: failed test4: passed test5: failed distinctInv does not have distinct records -----------------------------------
Submit the following:
1. Printed source code of only your contribution, not the entire source code (to get any credit the program has to work). 2. Printed output from ten test cases. 3. Source code and the executable code on a diskette (name your source as project6.cpp and executable code as project6.exe). 4.
Self-evaluation
table.
|