-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
77 lines (73 loc) · 1.94 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<fstream>
#include<iostream>
#include<string.h>
#include "Dictionary.h"
#include "List.h"
using namespace std;
void mainMenu() //menu function
{
linkedList<Dictionary> list;
string word, meaning; //stores the word and meaning
char choice; //stores user choice for the actions
cout << "\e[1;35mInput 's' to terminate the program anytime.\e[0;37m" << endl;
while (choice != 's') //while loop until 's' is entered
{
cout << "\n\x1b[36mPlease select an action: " << endl << endl;
cout << "\t1. Read file data" << endl;
cout << "\t2. Write to file" << endl;
cout << "\t3. Print the list" <<endl;
cout << "\t4. Print the reverse list" <<endl;
cout << "\t5. Reverse the list" <<endl;
cout << "\t6. filterby letter" <<endl;
cout << "\t7. Rearrange by length" <<endl;
cout << "\x1b[0m"; cin >> choice; cout << endl;
switch(choice) //switch statement to check user input and calling respective functions
{
case('1'):
{
readFileData(&(list.head));
}; break;
case('2'):
{
writeToFile(list.head);
}; break;
case('3'):
{
printList(list.head);
}; break;
case('4'):
{
printnodereverse(list.head);
}; break;
case('5'):
{
list.head = reverseList(list.head);
writeToFile(list.head);
}; break;
case('6'):
{
string let;
cout<<"Search for : ";
cin>>let;
list.head = filterByLetters(list.head, let);
writeToFile(list.head);
}; break;
case('7'):
{
list.head = rearrangeByEvenOddLength(list.head);
writeToFile(list.head);
}; break;
case('s'):
{
cout << "\e[1;33mProgram terminated." << endl;
}; break;
default:
cout << "\x1b[31mInvalid action selected!\x1b[37m" << endl;
}
}
}
int main()
{
mainMenu(); //call the main menu function from Parser.h
return 0;
}