1: /** @file linked_node_main.cpp
2: Illustrates various operations on a sequence of linked nodes.
3: */
5: #include <iostream>
6: using namespace std;
8: #include "utilities.h"
9: using Scobey::Pause;
10: using Scobey::Menu;
12: #include "linked_node_functions.h"
14: int main()
15: {
16: Menu m("Menu");
17: m.addOption("Quit");
18: m.addOption("Get info");
19: m.addOption("Build a new sequence of fixed size");
20: m.addOption("Display all node data values in current sequence");
21: m.addOption("Find location of first node containing given data value");
22: m.addOption("Add new node after first node containing given data value");
23: m.addOption("Add new node before first node containing given data value");
24: m.addOption("Delete first node containing given data value");
25: m.addOption("Reverse digits of data value in each node");
27: NodePointer head;
28: InitializeSequence(head);
29: int menuChoice;
30: do
31: {
32: m.display();
33: menuChoice = m.getChoice();
34: switch (menuChoice)
35: {
36: case -1:
37: case 1: Pause(0, "Program is now terminating."); break;
38: case 2: DescribeProgram(); break;
39: case 3: BuildSequenceFixedSize(head); break;
40: case 4: PrintNodeValues(head); Pause(); break;
41: case 5: FindDataValues(head); break;
42: case 6: InsertAfterNodeWithDataValue(head); break;
43: case 7: InsertBeforeNodeWithDataValue(head); break;
44: case 8: DeleteNodeWithDataValue(head); break;
45: case 9: ProcessAllNodes(head, ReverseAllDigits); break;
46: }
47: }
48: while (menuChoice != 1 && menuChoice != -1);
49: }