-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
440 lines (432 loc) · 14 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
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
#include <bits/stdc++.h>
using namespace std;
#include "classes.cpp"
int main()
{
system("clear");
int currentdate = 0;
user ouruser;
userdata userbase;
user xu, yu, zu, au, bu;
xu.username = "admin";
xu.password = "admin";
xu.id = 1;
xu.type = 3;
userbase.userdatabase.push_back(xu);
yu.username = "1234";
yu.password = "1234";
yu.id = 2;
yu.type = 3;
userbase.userdatabase.push_back(yu);
zu.username = "prof";
zu.password = "prof";
zu.id = 3;
zu.type = 1;
userbase.userdatabase.push_back(zu);
au.username = "stud";
au.password = "stud";
au.id = 4;
au.type = 2;
userbase.userdatabase.push_back(au);
bu.username = "lib";
bu.password = "lib";
bu.id = 5;
bu.type = 3;
userbase.userdatabase.push_back(bu);
books tbook;
booksdata bookbase;
books x, y, z, a, b;
x.name = "Harrypotter";
x.author = "JK Rowling";
x.avail = 1;
x.isbn = 1;
x.booker = 100000;
x.publication = "penguin";
x.issuedate = 100000;
bookbase.booksdatabase.push_back(x);
y.name = "Peak";
y.author = "Thomas";
y.avail = 0;
y.isbn = 2;
y.booker = 3;
y.publication = "galaxy books";
y.issuedate = 10;
bookbase.booksdatabase.push_back(y);
z.name = "Theriver";
z.author = "Sim Johns";
z.avail = 1;
z.isbn = 3;
z.booker = 100000;
z.issuedate = 100000;
z.publication = "Hill books";
bookbase.booksdatabase.push_back(z);
a.name = "Planetearth";
a.author = "RD Downey";
a.avail = 0;
a.isbn = 4;
a.booker = 4;
a.publication = "Rock water firm";
a.issuedate = 10;
bookbase.booksdatabase.push_back(a);
b.name = "Oceansdrives";
b.author = "Tupic Reynolds";
b.avail = 0;
b.isbn = 5;
b.booker = 3;
b.publication = "mongovier books";
b.issuedate = 5;
bookbase.booksdatabase.push_back(b);
for (;;)
{
cout << "LIBRARY SOFTWARE"
<< "\n\n";
cout << "Enter username:";
cin >> ouruser.username;
cout << "Enter password:";
cin >> ouruser.password;
user userour;
int usertype;
userour = userbase.search(ouruser, 0);
usertype = userour.type;
start:
cout << "Current date:" << currentdate;
if (usertype == 0)
{
cout << "\n\nInvaild username or password\nPlease Try again\n\n";
continue;
}
else if (usertype == 1)
{
professor prof;
int command;
cout << "\nenter 1: To see list of all books \nenter 2: To see list of your books\nenter 3: diaplay all available books\nenter 4: To check your fine\nenter 5: To search book\nenter 6: To issue the book\nenter 0: To exit\n\n";
cin >> command;
system("clear");
if (command == 1)
{
bookbase.displayall();
goto start;
}
else if (command == 2)
{
bookbase.listuserbook(userour);
goto start;
}
else if (command == 3)
{
bookbase.displayallavail();
goto start;
}
else if (command == 4)
{
int fint;
fint = bookbase.checkfine(userour, currentdate);
cout << "\nThe user's fine is: ₹" << fint << "\n";
goto start;
}
else if (command == 5)
{
books ebook, r;
cout << "Enter name of the book:";
cin >> ebook.name;
r = bookbase.search(ebook);
if (r.isbn)
{
cout << "\nName:";
cout << r.name << "\n";
cout << "ISBN:" << r.isbn << "\n";
cout << "Publication:" << r.publication << "\n";
cout << "Author:" << r.author << "\n";
cout << "Availibility:" << r.avail << "\n";
}
else
{
cout << "\nBook not found\n";
}
goto start;
}
else if (command == 6)
{
books ibook, r;
cout << "Enter name of the book:";
cin >> ibook.name;
r = bookbase.search(ibook);
bookbase.issue(r, userour, currentdate);
goto start;
}
else if (command == 0)
{
continue;
}
else
{
cout << "Invalid command entered\nPlease try again\n";
goto start;
}
}
else if (usertype == 2)
{
student stud;
int command;
cout << "\nenter 1: To see list of all books \nenter 2: To see list of your books\nenter 3: diaplay all available books\nenter 4: To check your fine\nenter 5: To search book\nenter 6: To issue the book\nenter 0: To exit\n\n";
cin >> command;
system("clear");
if (command == 1)
{
bookbase.displayall();
goto start;
}
else if (command == 2)
{
bookbase.listuserbook(userour);
goto start;
}
else if (command == 3)
{
bookbase.displayallavail();
goto start;
}
else if (command == 4)
{
int fint;
fint = bookbase.checkfine(userour, currentdate);
cout << "\nThe user's fine is: ₹" << fint << "\n";
goto start;
}
else if (command == 5)
{
books ebook, r;
cout << "Enter name of the book:";
cin >> ebook.name;
r = bookbase.search(ebook);
if (r.isbn)
{
cout << "\nName:";
cout << r.name << "\n";
cout << "ISBN:" << r.isbn << "\n";
cout << "Publication:" << r.publication << "\n";
cout << "Author:" << r.author << "\n";
cout << "Availibility:" << r.avail << "\n";
}
else
{
cout << "\nBook not found\n";
}
goto start;
}
else if (command == 6)
{
books ibook, r;
cout << "Enter name of the book:";
cin >> ibook.name;
r = bookbase.search(ibook);
bookbase.issue(r, userour, currentdate);
goto start;
}
else if (command == 0)
{
continue;
}
else
{
cout << "Invalid command entered\nPlease try again\n";
goto start;
}
}
else if (usertype == 3)
{
librarian libr;
int command;
cout << "\nenter 1: To see list of all books\nenter 2: To edit user database\nenter 3: To edit book database\nenter 4: To display all users\nenter 5: To see the list of books of a user\nenter 6: To change current date\nenter 7: To check user's fine\nenter 8: To clear user's fine\nenter 0: To exit\n\n";
cin >> command;
system("clear");
if (command == 1)
{
bookbase.displayall();
goto start;
}
else if (command == 2)
{
start2:
cout << "\nenter 1: To add user\nenter 2: To update user\nenter 3: To delete user\nenter 4: To search the user\nenter 0: To exit\n\n";
int comd;
cin >> comd;
system("clear");
if (comd == 1)
{
cout << "\nAdd User";
user newuse;
userbase.add(newuse);
goto start2;
}
else if (comd == 2)
{
cout << "\nUpadate User";
user upuser;
cout << "\nEnter username of the user:";
cin >> upuser.username;
userbase.update(upuser);
goto start2;
}
else if (comd == 3)
{
cout << "\nDelete User";
user deuser;
cout << "\nEnter username of the user:";
cin >> deuser.username;
userbase.delet(deuser);
goto start2;
}
else if (comd == 4)
{
cout << "\nSearch User";
int t;
user seuser, r;
cout << "\nEnter username of the user:";
cin >> seuser.username;
r = userbase.search(seuser, 1);
if (r.type)
{
cout << "\nUsername:";
cout << r.username << "\n";
cout << "ID:" << r.id << "\n";
cout << "Password:" << r.password << "\n";
cout << "Type:" << r.type << "\n";
}
else
{
cout << "\nUser not found\n";
}
goto start2;
}
else if (comd == 0)
{
goto start;
}
else
{
cout << "Invalid command entered\nPlease try again\n";
goto start2;
}
}
else if (command == 3)
{
start3:
cout << "\nenter 1: To add book\nenter 2: To update book\nenter 3: To delete book\nenter 4: To search the book\nenter 0: To exit\n\n";
int comd;
cin >> comd;
system("clear");
if (comd == 1)
{
cout << "\nAdd Book";
books newbook;
bookbase.add(newbook);
goto start3;
}
else if (comd == 2)
{
cout << "\nUpadate Book";
books upbook;
cout << "\nEnter name of the book:";
cin >> upbook.name;
bookbase.update(upbook);
goto start3;
}
else if (comd == 3)
{
cout << "\nDelete Book";
books debook;
cout << "\nEnter name of the book:";
cin >> debook.name;
bookbase.delet(debook);
goto start3;
}
else if (comd == 4)
{
cout << "\nSearch Book";
books sebook, r;
cout << "\nEnter name of the book:";
cin >> sebook.name;
r = bookbase.search(sebook);
if (r.isbn)
{
cout << "\nName:";
cout << r.name << "\n";
cout << "ISBN:" << r.isbn << "\n";
cout << "Publication:" << r.publication << "\n";
cout << "Author:" << r.author << "\n";
cout << "Availibility:" << r.avail << "\n";
cout << "Booker's id:" << r.booker << "\n";
cout << "Issue date:" << r.issuedate << "\n";
}
else
{
cout << "\nBook not found\n";
}
goto start3;
}
else if (comd == 0)
{
goto start;
}
else
{
cout << "\nInvalid command entered\nPlease try again\n";
goto start3;
}
}
else if (command == 4)
{
userbase.displayall();
goto start;
}
else if (command == 5)
{
user luser, rs;
cout << "\nEnter username of the user:";
cin >> luser.username;
rs = userbase.search(luser, 1);
bookbase.listuserbook(rs);
goto start;
}
else if (command == 6)
{
int dt;
cout << "\nIncrease current date by:";
cin >> dt;
currentdate += dt;
goto start;
}
else if (command == 7)
{
int fint;
user suser, rs;
cout << "\nEnter username of the user:";
cin >> suser.username;
rs = userbase.search(suser, 1);
fint = bookbase.checkfine(rs, currentdate);
cout << "\nThe user's fine is: ₹" << fint << "\n";
goto start;
}
else if (command == 8)
{
user fuser, rt;
cout << "\nEnter username of the user:";
cin >> fuser.username;
rt = userbase.search(fuser, 1);
bookbase.clearfine(rt, currentdate);
goto start;
}
else if (command == 0)
{
continue;
}
else
{
cout << "Invalid command entered\nPlease try again\n";
goto start;
}
}
return 0;
}
}