| 24 | SharedBox findSmallestBox(const Truckload& truckload); |
| 25 | |
| 26 | int main() |
| 27 | { |
| 28 | Truckload load1; // Create an empty list |
| 29 | |
| 30 | // Add 12 random Box objects to the list |
| 31 | const size_t boxCount{ 12 }; |
| 32 | for (size_t i{}; i < boxCount; ++i) |
| 33 | load1.addBox(randomSharedBox()); |
| 34 | |
| 35 | std::cout << "The first list:\n"; |
| 36 | load1.listBoxes(); |
| 37 | |
| 38 | // Copy the truckload |
| 39 | Truckload copy{ load1 }; |
| 40 | std::cout << "The copied truckload:\n"; |
| 41 | copy.listBoxes(); |
| 42 | |
| 43 | // Find the largest Box in the list |
| 44 | const auto largestBox{ findLargestBox(load1) }; |
| 45 | |
| 46 | std::cout << "\nThe largest box in the first list is "; |
| 47 | largestBox->listBox(); |
| 48 | std::cout << std::endl; |
| 49 | load1.removeBox(largestBox); |
| 50 | std::cout << "\nAfter deleting the largest box, the list contains:\n"; |
| 51 | load1.listBoxes(); |
| 52 | |
| 53 | const size_t nBoxes{ 20 }; // Number of vector elements |
| 54 | std::vector<SharedBox> boxes; // Array of Box objects |
| 55 | |
| 56 | for (size_t i{}; i < nBoxes; ++i) |
| 57 | boxes.push_back(randomSharedBox()); |
| 58 | |
| 59 | Truckload load2{ boxes }; |
| 60 | std::cout << "\nThe second list:\n"; |
| 61 | load2.listBoxes(); |
| 62 | |
| 63 | const auto smallestBox{ findSmallestBox(load2) }; |
| 64 | |
| 65 | std::cout << "\nThe smallest box in the second list is "; |
| 66 | smallestBox->listBox(); |
| 67 | std::cout << std::endl; |
| 68 | } |
| 69 | |
| 70 | SharedBox findLargestBox(const Truckload& truckload) |
| 71 | { |
nothing calls this directly
no test coverage detected