-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLibraryManagementSystem.cpp
More file actions
102 lines (89 loc) · 2.39 KB
/
Copy pathLibraryManagementSystem.cpp
File metadata and controls
102 lines (89 loc) · 2.39 KB
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
93
94
95
96
97
98
99
100
101
102
#include<iostream>
#include<fstream>
using namespace std;
class temp{
string id,name,author,search;
fstream file;
public:
void addBook();
void showAll();
void extractBook();
}obj;
int main(){
char choice;
cout<<"----------------------------------"<<endl;
cout<<"1-Show All Books"<<endl;
cout<<"2-Extract Book"<<endl;
cout<<"3-Add books(ADMIN)"<<endl;
cout<<"4-Exit"<<endl;
cout<<"----------------------------------"<<endl;
cout<<"Enter Your Choice :: ";
cin>>choice;
switch(choice){
case '1':
cin.ignore();
obj.showAll();
break;
case '2':
cin.ignore();
obj.extractBook();
break;
case '3':
cin.ignore();
obj.addBook();
break;
case '4':
return 0;
break;
default:
cout<<"Invalid Choice...!";
}
return 0;
}
void temp :: addBook(){
cout<<"\nEnter Book ID :: ";
getline(cin,id);
cout<<"Enter Book Name :: ";
getline(cin,name);
cout<<"Enter Book's Author name :: ";
getline(cin,author);
file.open("bookData.txt",ios :: out | ios :: app);
file<<id<<"*"<<name<<"*"<<author<<endl;
file.close();
}
void temp :: showAll(){
file.open("bookData.txt",ios :: in);
getline(file,id,'*');
getline(file,name,'*');
getline(file,author,'\n');
cout<<"\n\n";
cout<<"\t\t Book Id \t\t\t Book Name \t\t\t Author's Name"<<endl;
while(!file.eof()){
cout<<"\t\t "<<id<<" \t\t\t\t "<<name<<" \t\t\t "<<author<<endl;
getline(file,id,'*');
getline(file,name,'*');
getline(file,author,'\n');
}
file.close();
}
void temp :: extractBook(){
showAll();
cout<<"Enter Book Id :: ";
getline(cin,search);
file.open("bookData.txt",ios :: in);
getline(file,id,'*');
getline(file,name,'*');
getline(file,author,'\n');
cout<<"\n\n";
cout<<"\t\t Book Id \t\t\t Book Name \t\t\t Author's Name"<<endl;
while(!file.eof()){
if(search == id){
cout<<"\t\t "<<id<<" \t\t\t "<<name<<" \t\t\t "<<author<<endl;
cout<<"Book Extracted Successfully...!";
}
getline(file,id,'*');
getline(file,name,'*');
getline(file,author,'\n');
}
file.close();
}