///////////////////////////////////////////////////////////////////// // PointsCollection.cpp - Create and Operate on collections of Points // // Jim Fawcett, CSE687-OnLine, Summer 2017 // #include "PointsCollection.h" #ifdef TEST_POINTSCOLLECTION int main() { std::cout << "\n Testing PointsCollection"; std::cout << "\n ==========================\n"; PointsCollection points; Point p1(1.5, 2, 3.25); points.add(p1); Point p2(2, -3.333, 4); points.add(p2); Point p3(10.2, -9.3, 8.4); points.add(p3); // this demo collection is small enough to show on one line bool expandShow = false; std::cout << "\n Showing Collection"; std::cout << "\n --------------------"; points.show(expandShow); std::cout << "\n"; std::cout << "\n adding point to all members with PointsCollection::doOp"; std::cout << "\n ------------------------------------------------------------"; /* * - demonstrates use of collection's doOp method * - Callable is a callable object and, here, is assigned to a lambda * we created just for this demo */ Point pointToAdd(-1, +1.5, -1, "point to add"); pointToAdd.show(); std::cout << "\n"; // defining Callable object with local lambda PointsCollection::Callable co = [&](Point& cPoint) { cPoint += pointToAdd; }; // applying to each member of collection points.doOp(co); std::cout << "\n Showing Collection"; std::cout << "\n --------------------"; points.show(expandShow); std::cout << "\n\n"; } #endif