/////////////////////////////////////////////////////////////// // lpath.cpp -- represents a labeled path of points // // ver 1.2 // // // // Language: Visual C++, ver 6.0 // // Platform: Dell OptiPlex Gs, Win NT 4.0, sp 3 // // Application: Example for ECS500 // // Author: Jim Fawcett, CST 2-187, Syracuse Univ. // // (315) 443-3948, fawcett@ecs.syr.edu // /////////////////////////////////////////////////////////////// #ifdef TEST_LPATH #include #include #include #include "lpath.h" #include "lpoint.h" using namespace std; void main() { cout << "\n Testing lpath class " << "\n ---------------------\n\n"; cout << "\n Testing sizing constructor " << "\n ----------------------------\n\n"; lpath P(15, string("P lpath")); cout << "physical size of P is " << P.max() << '\n' << " logical size of P is " << P.size() << '\n'; string temp = P.label(); cout << " label of P is " << temp << "\n\n"; lpoint p1(3.5,-7.2,string("point p1")); cout << "\n Testing add function " << "\n ----------------------\n\n"; P.add(p1).add(p1).add(p1); cout << " P = " << P << endl; cout << "\n Testing indexing " << "\n ------------------\n\n"; cout << " the second element of P is: " << P[1] << "\n\n"; lpoint p2(1.1,2.2,"point p2"); P[0] = p2; cout << " after P[0] = p2, e.g. " << p2 << P << "\n\n"; cout << "\n Testing assignment " << "\n --------------------\n\n"; lpath P1(10,"path P1"); P1 = P; cout << " after P1 = P:" << P1 << "\n\n"; // cout << "\n Testing writing to and reading from files " << "\n -------------------------------------------\n\n"; ofstream out("test.dat"); if(out.good()) out << P << P1; cout << " sending paths:" << P << P1 << " to file test.dat\n\n"; out.close(); ifstream in("test.dat"); if(in.good()) in >> P >> P1; cout << " getting paths:" << P << P1 << " from file test.dat\n\n"; } #endif