/* simple program to test choral ring implementation */ #include #include using namespace std; void printMenu(); #include "ring.h" int main() { char choice = '1'; // user's choice int n,k, moves, remnode; ring r; ring f; while (choice != '8') { printMenu(); cout << "\tChoice? "; cin >> choice ; switch (choice) { case ('1') : cout << "Please enter n and k " << endl; if (!(cin >> n >> k) || n < 5 || k < 2 || k > n/2) cout << "Invalid input " << endl; else r.create(n,k); f(r); break; case ('2') : if (!r.empty()) r.dumpShort();f.dumpShort() ;break; case ('3') : if (!r.empty()) r.dumpLong(); f.dumpLong() ;break; case ('4') : if (!r.empty()) r.display(); f.display(); break; case ('5') : cout << "Please enter number of places to move "; cin >> moves; if (moves < 0) cout << "Invalid input " << endl; else if (!r.empty()) r.move(moves); f.move(moves); break; case('6') : if (!r.empty()) cout << r.getCurrent() << endl; cout << f.getCurrent() << endl; break; case('7') : cout << "Please enter label of node to be removed "; cin >> remnode; if (remnode > 0 && r.hasMember(remnode) && f.hasMember(remnode)) { //r.remove(remnode); f.remove(remnode); } else cout << remnode <<" does not exist " << endl; case('8') : break; default : cout << "Invalid input " << endl; } } return EXIT_SUCCESS; } void printMenu() { /* displays a menu of options */ cout << "\n\n\t\tChordal Rings " << endl << endl; cout << "\t1 Create a Ring " << endl; cout << "\t2 Dump Short " << endl; cout << "\t3 Dump Long " << endl; cout << "\t4 Display Ring " << endl; cout << "\t5 Move " << endl; cout << "\t6 Display Current " << endl; cout << "\t7 Remove " << endl; cout << "\t8 Quit " << endl << endl; }