| 15 | } |
| 16 | |
| 17 | int main() |
| 18 | { |
| 19 | const double limit {99.0}; // Upper limit on Box dimensions |
| 20 | auto random = createUniformPseudoRandomNumberGenerator(limit); |
| 21 | |
| 22 | Truckload load; |
| 23 | const size_t boxCount {16}; // Number of Box object to be created |
| 24 | |
| 25 | // Create boxCount Box objects |
| 26 | for (size_t i {}; i < boxCount; ++i) |
| 27 | load.addBox(std::make_shared<Box>(random(), random(), random())); |
| 28 | |
| 29 | std::cout << "The boxes in the Truckload are:\n"; |
| 30 | std::cout << load; |
| 31 | |
| 32 | // Find the largest Box in the Truckload |
| 33 | double maxVolume {}; |
| 34 | size_t maxIndex {}; |
| 35 | size_t i {}; |
| 36 | while (load[i]) |
| 37 | { |
| 38 | if (load[i]->volume() > maxVolume) |
| 39 | { |
| 40 | maxIndex = i; |
| 41 | maxVolume = load[i]->volume(); |
| 42 | } |
| 43 | ++i; |
| 44 | } |
| 45 | |
| 46 | std::cout << "\nThe largest box is: "; |
| 47 | std::cout << *load[maxIndex] << std::endl; |
| 48 | |
| 49 | load.removeBox(load[maxIndex]); |
| 50 | std::cout << "\nAfter deleting the largest box, the Truckload contains:\n"; |
| 51 | std::cout << load; |
| 52 | } |
nothing calls this directly
no test coverage detected