-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.h
211 lines (202 loc) · 4 KB
/
header.h
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<conio.h>
#include<windows.h>
#include<bits/stdc++.h>
using namespace std;
//static int find_id[9999];
void menu();
void add_books();
void book_list();
void delete_book();
void delete_by_id();
void delete_by_name();
void edit_book();
void search_book();
void search_by_id();
void search_by_name();
void issue_book();
void design();
void gotoxy (int x, int y);
int checkid(int t);
int checkname(string t);
string getidline(int t);
string getnameline(string t);
string getnamebyid(int t);
int numofrecord();
int numofrecordissue();
void template_use();
static int n;
class books
{
//char cat[15];
//int id;
protected:
string name;
string author;
int qty;
// int rackno;
// int num;
string price;
// int qrack;
public:
int num;
int id;
string cat;
int rackno;
//void edit();
virtual void show()
{
}
void friend operator>>(istream &input, books &B)
{
a:
system("cls");
design();
gotoxy(21,5);
cout<<"Book id: ";
input>>B.id;
if(checkid(B.id)==0)
{
gotoxy(20,13);
cout<<"ID already Exist"<<endl;
gotoxy(20,14);
cout<<"Press any key to continue"<<endl;
char c[2];
cin>>c;
if(c) goto a;
}
gotoxy(21,6);
cout<<"Book Name: ";
input>>B.name;
gotoxy(21,7);
cout<<"Author: ";
input>>B.author;
gotoxy(21,8);
cout<<"Quantity: ";
input>>B.qty;
gotoxy(21,9);
cout<<"Price: ";
input>>B.price;
gotoxy(21,10);
cout<<"Rack No: ";
input>>B.rackno;
//cat="Computer";
}
void output()
{
ofstream fout("book.txt",ios::app);
fout<<id<<" "<<cat<<" "<<name<<" "<<author<<" "<<qty<<" "<<price<<" "<<rackno<<endl;
//B.output();
}
void getdata_from_file(string line)
{
//string line;
stringstream sin(line);
int val;
sin>>val;
id=val;
string ch;
sin>>ch;
cat=ch;
string cha;
sin>>cha;
name=cha;
string chb;
sin>>chb;
author=chb;
int val1;
sin>>val1;
qty=val1;
string chc;
sin>>chc;
price=chc;
int val2;
sin>>val2;
rackno=val2;
}
//void putdata()
friend ostream& operator<<(ostream &cout, books &B)
{
//gotoxy(20,n);
//n++;
cout<<setw(3)<<B.id<<" "<<setw(13)<<B.cat<<" "<<setw(22)<<B.name<<" "<<setw(13)<<B.author<<" "<<setw(6)<<B.qty<<" "<<setw(9)<<B.price<<" "<<setw(8)<<B.rackno<<endl;
}
void edit()
{
cout<<"\t\t\tBook Name: ";
cin>>name;
cout<<"\t\t\tAuthor: ";
cin>>author;
cout<<"\t\t\tQuantity: ";
cin>>qty;
cout<<"Price: ";
cin>>price;
cout<<"\t\t\tRack No: ";
cin>>rackno;
}
void getbookname(string s)// used for derive class //***polymorphism ***
{
name=s;
}
};
/*void books::edit()
{
gotoxy(21,6);
cout<<"Book Name: ";
cin>>name;
gotoxy(21,7);
cout<<"Author: ";
cin>>author;
gotoxy(21,8);
cout<<"Quantity: ";
cin>>qty;
gotoxy(21,9);
cout<<"Price: ";
cin>>price;
gotoxy(21,10);
cout<<"Rack No: ";
cin>>rackno;
}*/
class student:public books
{
public:
string stname;
int roll;
void show();
void view();
student()
{
stname=' ';
roll=0;
}
student(student &A)
{
stname=A.stname;
roll=A.roll;
}
string showbookname()
{
return name;
}
friend ostream& operator<<(ofstream &fout, student &s)
{
fout<<setw(3)<<s.id<<" "<<setw(25)<<s.showbookname()<<" "<<setw(15)<<s.stname<<" "<<setw(16)<<s.roll<<endl;
}
};
template<typename T>
class library
{
T v;
public:
//void getdata();
T putdata()
{
return v;
}
void getdata(T s)
{
v=s;
}
};