// File: p5main2.cpp // // Tests ZoomTable functionality. // #include #include #include "ZoomTable.H" using namespace std ; void PrintNode(Node* ptr) { if (ptr == NULL) { cout << "NULL!!! " ; } else { cout << "(" << ptr->row() << "," << ptr->col() << ")=" << ptr->get() << "\n" ; } } int main() { ZoomTable Z(5,7,0) ; Node *ptr ; cout << "Z has " << Z.rows() << " rows and " << Z.cols() << " columns.\n\n" ; // After these insertions and deletions, the ZoomTable // should look like the diagram in the project description. Z.insert(0,5,41) ; Z.insert(0,6,42) ; Z.insert(0,4,43) ; Z.insert(0,0,44) ; Z.remove(0,5) ; Z.insert(1,3,45) ; Z.insert(1,4,46) ; Z.insert(4,6,47) ; Z.insert(2,1,48) ; Z.insert(2,4,49) ; Z.insert(3,5,27) ; Z.insert(2,5,50) ; Z.insert(3,0,51) ; Z.insert(4,0,52) ; Z.insert(3,3,17) ; Z.insert(1,6,54) ; Z.insert(4,4,37) ; Z.insert(3,3,56) ; ptr = Z.find(2,4) ; Z.remove(ptr) ; ptr = Z.find(3,5) ; ptr->set(49) ; Z.insert(4,4,55) ; cout << "\nPrint out row by row: \n" ; ZTRowIterator it ; for (int row = 0 ; row < Z.rows() ; row++) { for (it = Z.RowBegin(row) ; it != Z.RowEnd(row) ; it++) { cout << setw(5) << *it << " " ; } cout << endl ; } cout << "\nPrint out column by column: \n" ; ZTColIterator it2 ; for (int col = 0 ; col < Z.cols() ; col++) { for (it2 = Z.ColBegin(col) ; it2 != Z.ColEnd(col) ; it2++) { cout << setw(5) << *it2 << " " ; } cout << endl ; } }