Skip to content

Commit 3750eff

Browse files
author
sharafALmikhlafi01~
committed
The menu of program
1 parent 1335c6a commit 3750eff

File tree

3 files changed

+86
-21
lines changed

3 files changed

+86
-21
lines changed

src/include/LineLinkedList/LineLinkedList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class LineLinkedList
135135

136136
TEMP_HEAD = TEMP_HEAD->NEXT;
137137
}
138-
138+
139139
return -1;
140140
}
141141

src/include/menu/menu.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#pragma once
2+
#include<iostream>
3+
#include "../LineLinkedList/LineLinkedList.h"
4+
#include "../MasterLinkedList/MasterLinkedList.h"
5+
using namespace std;
6+
class menu{
7+
public:
8+
void displayMenu(){
9+
LinkedListProcessor processor("assets/data.txt");
10+
processor.processFile();
11+
MasterLinkedList masterList = processor.getMasterList();
12+
13+
// MasterLinkedList masterList;
14+
LineLinkedList lineLinked;
15+
int num_oper;
16+
int indx;
17+
string word;
18+
19+
do{
20+
21+
cout<<"1- For display the file\n";
22+
cout<<"2- For display specific line\n";
23+
cout<<"3- For display number of line in the file\n";
24+
cout<<"4- For display number of letter in the file\n";
25+
cout<<"5- For display number of letter in specific line\n";
26+
cout<<"6- For search for word in the file\n";
27+
cout<<"7- For exit\n";
28+
cout<<"Enter number of operation :";
29+
cin>>num_oper;
30+
cout<<"\n======================================================\n\n";
31+
32+
switch (num_oper)
33+
{
34+
case 1:
35+
masterList.display();
36+
break;
37+
38+
case 2:{
39+
cout<<"Enter number of line :";
40+
cin>>indx;
41+
masterList.displayByLineIndex(indx);
42+
}
43+
break;
44+
45+
case 3:
46+
cout<<masterList.getLinesCount()<<endl;
47+
break;
48+
49+
case 4:
50+
cout<<lineLinked.getLettersCount()<<"\n";
51+
break;
52+
53+
case 5:{
54+
cout<<"Enter number of line :";
55+
cin>>indx;
56+
cout<<lineLinked.getLettersCountByWordIndex(indx);
57+
}
58+
break;
59+
60+
case 6:
61+
cout<<"Enter the word you want to search :";
62+
cin>>word;
63+
lineLinked.searchByWord(word);
64+
break;
65+
66+
case 7:
67+
exit(0);
68+
69+
default:
70+
break;
71+
}
72+
}while(num_oper>0&&num_oper<8);
73+
}
74+
75+
// void creatFile(){
76+
// LinkedListProcessor processor("assets/data.txt");
77+
// processor.processFile();
78+
// MasterLinkedList masterList = processor.getMasterList();
79+
// }
80+
81+
};

src/main.cpp

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,14 @@
11
#include <iostream>
22
#include <string>
33
#include "include/LinkedListProcessor/LinkedListProcessor.h"
4+
#include "include/menu/menu.h"
45
using namespace std;
56

6-
void br(int n = 2);
7-
87
int main()
98
{
10-
cout << "Program Start";
11-
br();
12-
13-
LinkedListProcessor processor("assets/data.txt");
14-
processor.processFile();
15-
MasterLinkedList masterList = processor.getMasterList();
16-
masterList.display();
17-
cout << endl << "Total lines: " << masterList.getLinesCount();
18-
19-
br();
9+
menu M;
10+
cout << "Program Start\n";
11+
M.displayMenu();
2012
cout << "Program End";
2113
return 0;
2214
}
23-
24-
void br(int n)
25-
{
26-
for (int i = 0; i < n; i++)
27-
{
28-
cout << endl;
29-
}
30-
}

0 commit comments

Comments
 (0)