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