//////////////////////////////////////////////////////// // // circlemain.cpp // // Started 1/26/98 by Jeff Ondich // Last modified: 1/26/98 // // This program does a moderately thorough test of // an implementation of the IntCircle class. Serious // testing would require more--for example, testing // all member functions on an empty circle. // //////////////////////////////////////////////////////// #include #include "intcircle.h" int main( void ) { IntCircle myCircle; // Let's see how an empty circle gets printed, // and make sure Sum() and Size() work correctly // for empty circles. myCircle.Print(); cout << "Size: " << myCircle.Size() << endl; cout << "Sum: " << myCircle.Sum() << endl; // Very exciting. Now let's put a few integers // into our circle and print out the result to // make sure all is well. We'll also test Sum() // and Size() on this non-empty circle. myCircle.InsertItem( 6 ); myCircle.Print(); myCircle.InsertItem( 23 ); myCircle.Print(); myCircle.InsertItem( -1 ); myCircle.Print(); myCircle.InsertItem( 4 ); myCircle.Print(); cout << "Size: " << myCircle.Size() << endl; cout << "Sum: " << myCircle.Sum() << endl; // Try out ++ and --. ++myCircle; ++myCircle; myCircle.Print(); --myCircle; myCircle.Print(); // That last printout should show -1 as the first // node. Let's remove it. myCircle.RemoveFirstItem(); myCircle.Print(); // Time to try out the = operator. We'll // need a new circle for that. IntCircle anotherCircle; anotherCircle.InsertItem( 99 ); anotherCircle.InsertItem( 678 ); anotherCircle.InsertItem( 3 ); anotherCircle.Print(); myCircle = anotherCircle; myCircle.Print(); anotherCircle.Print(); // Just in case we did operator= wrong, // let's make changes to myCircle and anotherCircle // to make sure those changes don't affect // both circles. myCircle.RemoveFirstItem(); anotherCircle.InsertItem( 55 ); myCircle.Print(); anotherCircle.Print(); // All done for now. return( 0 ); }