-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbook_list.cpp
92 lines (77 loc) · 2.36 KB
/
book_list.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include"header.h"
void book_list()
{
system("cls");
int s=numofrecord();
books b[s];
ifstream fin;
fin.open("book.txt");
string line;
int i=0;
/*getline(fin,line);
cout<<line;*/
//while(getline(fin,line))
for(int i=0; i<s; i++)
{
getline(fin,line);
b[i].getdata_from_file(line);
//cout<<b[i];
//i++;
}
//cout<<b[0];
/*for(int i=0;i<s;i++)
{
cout<<b[i];
//i++;
}*/
//cout<<b[i--]<<endl;
vector<books> vec;
for(int i=0; i<s; i++)
{
vec.push_back(b[i]);
}
sort(vec.begin(),vec.end(),[](books b1, books b2)
{
return b1.id<b2.id;
});
/*cout<<"_______AFTER SORTING w.r.t AGE_________"<<endl;
for_each(vec.begin(),vec.end(),[](books b)
{
cout<<b;
});*/
cout<<"\n\n\n\xB2\xB2\xB2\xB2\xB2\xB2\xB2 BOOK LIST \xB2\xB2\xB2\xB2\xB2\xB2\xB2\n"<<endl;
cout<<"\xDB\xDB\xB2 1.Show Book List by Entry\n"<<endl;
cout<<"\xDB\xDB\xB2 2.Show Book List by ID\n"<<endl;
cout<<"\xDB\xDB\xB2 3.Main Menu\n"<<endl;
cout<<"Enter your choice: ";
int sw;
cin>>sw;
if(sw==1)
{
system("cls");
cout<<" *************************************Book List*************************************"<<endl;
cout<<" ID CATEGORY BOOK NAME AUTHOR QTY PRICE RackNo "<<endl;
cout<<"_____________________________________________________________________________________\n"<<endl;
for(int i=0; i<s; i++)
{
cout<<b[i];
//i++;
}
cout<<"_____________________________________________________________________________________\n"<<endl;
cout<<"Enter m for main menu:";
char m;cin>>m;
if (m) menu();
}
if(sw==2)
{
system("cls");
cout<<" *************************************Book List*************************************"<<endl;
cout<<" ID CATEGORY BOOK NAME AUTHOR QTY PRICE RackNo "<<endl;
cout<<"_____________________________________________________________________________________\n"<<endl;
for_each(vec.begin(),vec.end(),[](books b){cout<<b;}); //Lambda Function (sort by id)
cout<<"Enter m for main menu:";
char m;cin>>m;
if (m) menu();
}
if(sw==3) menu();
}