-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.cpp
More file actions
1095 lines (875 loc) · 28.3 KB
/
Copy pathindex.cpp
File metadata and controls
1095 lines (875 loc) · 28.3 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
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//================== About this project ===================//
//------ ====== <<<<< Name >>>>> ===== --------//
// <<<< Library Management System — C++ | OOP | Design Patterns | SOLID >>>>>> //
//------ ====== <<<<< Description >>>>> ===== --------//
// <<<< Developed an object-oriented library system using C++ to manage members and books (EBook, HardCopy). Applied SOLID
// principles and implemented key design patterns including Singleton, Strategy, and Factory Method. >>>>> //
// <<<< Designed extensible class hierarchy using abstract classes (Book, User) >>>> //
// <<<< Enabled runtime polymorphism for unified book operations >>>> //
// <<<< Implemented BookSearchStrategy to support flexible, pluggable search logic >>>> //
// <<<< Used Singleton pattern for Library instance management >>>> //
// <<<< Applied exception handling and modular command logic >>>> //
// <<<< Documented code with clear structure and extensibility in mind >>>> //
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
//-----Used in auto BOOK ID generation--------//
int Bookisbn=2500;
//-----Used in auto User ID generation--------//
int UserId=2500001;
class HardCopy;
class EBook;
class BookSearchStrategy;
//------Book class Super class of all type of books---------//
class Book
{
private:
int BookISBN;
string Title;
string AuthorName;
double Price;
string Publisher;
protected:
string type;
int Edition;
public:
Book() {
}
Book(string,string,double,string);
int get_BookISBN();
void set_Title(string);
string get_Title();
void set_AuthorName(string);
string get_AuthorName();
void set_Publisher(string);
string get_Publisher();
void set_price(int);
int get_price();
virtual string get_Type() = 0;
virtual int get_Edition() = 0;
virtual void DisplayDetsils() = 0;
virtual void set_TotalCopies(int) = 0;
virtual void set_AvailableCopies(int) = 0;
virtual int get_TotalCopies() = 0;
virtual int get_AvailableCopies() = 0;
};
class EBook:public Book
{
private:
string DownloadLink;
public:
EBook(string,string,double,int,string,string);
void set_DownloadLink(string);
string get_DownloadLink();
void set_Edition(int);
int get_Edition();
string get_Type();
void DisplayDetsils();
//------EBOOK does not required these functions so these are
// implemented just to complete the abstract class
//---implemented by only a return statement so that we can use
//these class by overriding the virtual function of incomplete super class
void set_TotalCopies(int){return;};
int get_TotalCopies(){return 1;};
void set_AvailableCopies(int){return;};
int get_AvailableCopies(){return 1;};
};
//---HardCopy of Books------//
class HardCopy:public Book
{
private:
int TotalCopies=0;
int AvailableCopies=0;
public:
HardCopy():Book(){
}
HardCopy(string,string,double,string,int);
void set_TotalCopies(int);
int get_TotalCopies();
void set_AvailableCopies(int);
int get_AvailableCopies();
int get_Edition();
string get_Type();
void DisplayDetsils();
};
class User
{
private:
int userId;
string Password;
protected:
string name;
public:
User(string name) {
this->userId =++UserId;
this->name=name;
}
int get_userId(){
return userId;
}
Book* search(BookSearchStrategy *strategy,vector<Book*>,string);
bool isAvailable(int,vector<Book*>);
virtual void ViewInformation()=0;
//----These function is not implemented now it can be implemented when
// i add Authentication feature in LIBRARY MANAGENEMENT SYSTEM , but in this
// project i want to showcase my OOPs concept so i didn't implement it for now
// i will do it later.......
void Login();
void LohOut();
void ChangePassword();
};
//---Member class it stores information about member or user who is a
// student of library it means one object of class Member is an student of library
// who can borrow book and return it and can see the details of book he borrowed
class Member:public User
{
private:
vector<Book*> Borrowed;
public:
Member(string name_):User(name_){
}
void set_Name(string);
void set_StudentId(int);
void set_BorrowedBook(Book*);
vector<Book*>& get_BorrowedBook();
int get_userid(){
return get_userId();
}
string get_Name();
void DisplayDetails();
void viewBorrowedBook();
void ViewInformation(){
cout<<endl<<"name : "<<name<<endl;
cout<<"user id : "<<get_userId()<<endl;
};
};
//----========="OWNER" IT MEANS " ADMIN OF LIBRARY "=========----//
// owner has power to operate whole library an owner or admin can
// Add new Books, Remove Books , Add new Member in library, Remove the
// members from library , can see all the members of library , can
// see all the books of library, issue book to a student (member) of library ,
// collect the issued bool , see details of all the book borrowed by a specific maner (student)
// --in future it can be scalable if Owner want to add some staff in
//library in different position he can add staffs remove staffs see their
// details....etc......
class Owner:public User
{
public:
Owner(string name):User(name){
}
int get_userid(){
return get_userId();
}
void ViewInformation(){
cout<<endl<<"name : "<<name<<endl;
cout<<"user id : "<<get_userId()<<endl;
};
void AddBooks(vector<Book*> &,string,string,double,string,string,int,string);
void RemoveBook(vector<Book*> &,int,string);
User* FindMemberById(int,vector<User*> &);
void RegisterMember(string,vector<User*> &);
void RemoveMember(vector<User*> &);
void ViewAllBook(vector<Book*> &);
void ViewAllMembers(vector<User*> &);
void UpdateInformation(vector<Book*>&);
void IssueBook(Book &,Member &,vector<Book*>&);
void Collect_Book(Member &,vector<Book*> &);
};
//=====================LIBRARY==================//
//------The central management system of LIBRARY it is a singelton class
// it means only one library's instance can be formed
// it stores detail about all the user of library and books available in library
// it hold an instance of owner who is only owner of library and performed
// all the owner's behaviour , there is no other owner and method to add a
// new owner in future to make it scalable if owner want can add different staffs
// and assign them their access
class Library
{
private:
//=============== " CREATIONAL DESIGN PATERN " ===================//
//==========" SINGELTON "============//
//------By making private constructor and add a function to get instance
// Library become a singletion class and only one instance of library can
// be formed in whole programme
static Library* instance;
Library() : o1("Anmol") {
}
public:
static Library* getInstance() {
if (!instance)
instance = new Library();
return instance;
}
vector<Book*> Books;
vector<User*> AllMembers;
Owner o1;
Book* FindBookByISBN(int);
User* FindMemberById(int);
void DisplayAllAvailableBooks();
};
Library* Library::instance = nullptr;
//=============== " DESIGN PATERN " ===================//
//==========" STRATEGY "============//
//--BookSearcgStrategy class is a strategy (super) class of searching
// by making its subclass we can implement different type of searching
// but we didn't require to change our existing code to search book by
// different way by author by , by isbn number, by title,etc.....
// in this way by implementing strategy patern we follow :-
//
// "---===== " Open/Closed principle" =======-----"
// "---===== " sinle responsibility principle " ======----"
//
// in my project
class BookSearchStrategy
{
public:
virtual Book* search(vector<Book*>& books, const string& query) = 0;
};
class SearchByTitle : public BookSearchStrategy {
public:
Book* search(vector<Book*>& books, const string& query) override {
for (auto b : books)
if (b->get_Title() == query) return b;
return nullptr;
}
};
class SearchByIsbn : public BookSearchStrategy {
public:
Book* search(vector<Book*>& books, const string& query) override {
int isbn = stoi(query);
for (auto b : books)
if (b->get_BookISBN() == isbn) return b;
return nullptr;
}
};
//------------------------------------------------------Book-------------------------------------------------------------------------//
Book :: Book(string title,string authorName,double price,string publisher) {
BookISBN=++Bookisbn;
this->Title=title;
this->AuthorName=authorName;
this->Price=price;
this->Publisher=publisher;
}
void Book::set_Title(string s)
{
Title=s;
}
void Book::set_AuthorName(string s)
{
AuthorName=s;
}
void Book::set_Publisher(string s)
{
Publisher=s;
}
void Book::set_price(int n)
{
Price=n;
}
int Book::get_BookISBN()
{
return BookISBN;
}
string Book::get_Publisher()
{
return Publisher;
}
string Book::get_Title()
{
return Title;
}
string Book::get_AuthorName()
{
return AuthorName;
}
int Book::get_price()
{
return Price;
}
//------------------------------------------------------------------EBook---------------------------------------------------------------//
EBook::EBook(string title,string author,double price,int edition,string publisher,string link) : Book(title,author,price,publisher)
{
try
{
set_Edition(edition);
type="ebook";
this->DownloadLink=link;
}
catch(...)
{
cout<<endl<<"there is some exception in setting book "<<endl;
}
}
void EBook::set_DownloadLink(string s)
{
DownloadLink=s;
};
string EBook::get_Type()
{
return type;
}
string EBook::get_DownloadLink()
{
return DownloadLink;
}
void EBook::set_Edition(int n)
{
Edition=n;
}
int EBook::get_Edition()
{
return Edition;
}
//---- display details of book -----//
void EBook::DisplayDetsils()
{
cout<<endl<<"details of this book are given below : "<<endl;
cout<<endl<<"Type : EBook";
cout<<endl<<"title : "<<get_Title();
cout<<endl<<"author : "<<get_AuthorName();
cout<<endl<<"ISBN number : "<<get_BookISBN();
cout<<endl<<"publisher name : "<<get_Publisher();
cout<<endl<<"edition year : "<<get_Edition();
cout<<endl<<"price : "<<get_price()<<endl;
}
//---------------------------------------------------------HardCopy---------------------------------------------------------------//
HardCopy::HardCopy(string title,string author,double price,string publisher,int edition) : Book(title,author,price,publisher)
{
try
{
this->Edition=edition;
type="hardcopy";
}
catch(...)
{
cout<<endl<<"there is some exception in setting book "<<endl;
}
}
void HardCopy::set_TotalCopies(int n)
{
TotalCopies=n;
}
void HardCopy::set_AvailableCopies(int n)
{
AvailableCopies=n;
}
int HardCopy::get_TotalCopies()
{
return TotalCopies;
}
int HardCopy::get_AvailableCopies()
{
return AvailableCopies;
}
int HardCopy::get_Edition()
{
return Edition;
}
void HardCopy::DisplayDetsils()
{
cout<<endl<<"details of this book are given below : "<<endl;
cout<<endl<<"Type : HardCopy";
cout<<endl<<"title : "<<get_Title();
cout<<endl<<"author : "<<get_AuthorName();
cout<<endl<<"ISBN number : "<<get_BookISBN();
cout<<endl<<"publisher name : "<<get_Publisher();
cout<<endl<<"edition year : "<<get_Edition();
cout<<endl<<"price : "<<get_price()<<endl;
}
string HardCopy::get_Type()
{
return type;
}
//----------------------------------------------------------Member-------------------------------------------------------------------------//
void Member::set_Name(string s)
{
name=s;
}
string Member::get_Name()
{
return name;
}
void Member::DisplayDetails()
{
cout<<endl<<"name : "<<get_Name();
cout<<endl<<"student id : "<<get_userid()<<endl;
}
void Member::set_BorrowedBook(Book* h1)
{
Borrowed.push_back(h1);
cout<<endl<<"pushed"<<endl;
}
void Member::viewBorrowedBook()
{
cout<<endl<<"details of borrowed books are given below : "<<endl;
for(auto x:Borrowed)
{
x->DisplayDetsils();
}
}
vector<Book*>& Member::get_BorrowedBook()
{
return Borrowed;
}
//---------------------------------------------------------------------User----------------------------------------------------------------//
Book* User::search(BookSearchStrategy *strategy,vector<Book*> arr,string isbn)
{
return strategy->search(arr,isbn );
}
//----check the availability of book by isbn number-----//
bool User::isAvailable(int isbn,vector<Book*> arr)
{
for(auto x:arr)
{
if(x->get_BookISBN()==isbn)
return true;
}
return false;
}
//---------------------------------------------------------Owner--------------------------------------------------------------------//
void Owner::AddBooks(vector<Book*> &arr,string title,string author,double price,string publisher,string type,int edition,string link="")
{
//=============== " DESIGN PATERN " ===================//
//==========" STRATEGY "============//
//------By implementing book by this type we follow partial factory method
// we need to do aome smal change in this method if we add a new type of book
// eg. AudioBook (new sub class of book)
// we can make it fully factory method but ther se some sort of issue
// that each time we need to change the availablecopies and totalcopies
// of hardbook so if book is hardcopy implemntation somehow varies...
// so it is partial factory method design patern
if(type=="hardcopy")
{
Book *newBook=new HardCopy(title,author,price,publisher,edition);
arr.push_back(newBook);
cout<<"Hard copy of book added successfully"<<endl;
int count=0;
for(auto x:arr)
{
if(title==x->get_Title())
{
if(count<x->get_AvailableCopies())
count+=1;
x->set_AvailableCopies(x->get_AvailableCopies()+1);
}
}
newBook->set_AvailableCopies(newBook->get_AvailableCopies()+count);
cout<<"Hardcopy added successfully"<<endl;
}
else if(type=="ebook")
{
Book *newBook=new EBook(title,author,price,edition,publisher,link);
for(auto x:arr)
{
if(title==x->get_Title()&&edition==x->get_Edition()){
Bookisbn--;
throw 2;
}
}
arr.push_back(newBook);
cout<<"Ebook added successfully"<<endl;
}
}
void Owner::RemoveBook(vector<Book*> &arr,int isbn,string type)
{
try
{
//----check availability of book ---------//
if(!isAvailable(isbn,arr))
throw 3;
//----if available we get the book so that we can get title and change (decrease)
// Availablecopies and TotalCopies of all book have same title --------//
BookSearchStrategy *bs=new SearchByIsbn();
Book *h1= search(bs,arr,to_string(isbn));
int count=0;
for(auto x:arr)
{
if(x->get_BookISBN()==isbn)
{
arr.erase(arr.begin()+count);
cout<<endl<<"book removed successfully"<<endl;
if(type=="hardcopy")
{
for(auto x:arr){
if(h1->get_Title()==x->get_Title()){
x->set_AvailableCopies(x->get_AvailableCopies()-1);
x->set_TotalCopies(x->get_TotalCopies()-1);
}
}
}
break;
}
count++;
}
}
catch(int e)
{
if(e==3){cout<<endl<<"book not found in EBook"<<endl;}
}
catch(...)
{
cout<<endl<<"there is some exception in remove function"<<endl;
}
}
void Owner::RegisterMember(string name,vector<User*> &AllMembers)
{
Member *mem=new Member(name);
AllMembers.push_back(mem);
cout<<endl<<"membered registered "<<endl;
}
void Owner::RemoveMember(vector<User*> &AllMembers)
{
int id;
cout<<endl<<"enter the id of member you want to remove : ";
cin>>id;
User *mem=FindMemberById(id,AllMembers);
if(!mem)
throw 7;
Member* m = dynamic_cast<Member*>(mem);
if(m->get_BorrowedBook().size()!=0)
throw 8;
int count=0;
for(auto x:AllMembers)
{
if(x->get_userId()==id)
{
AllMembers.erase(AllMembers.begin()+count);
break;
}
count++;
}
cout<<endl<<"member removed sucessfully"<<endl;
}
User* Owner::FindMemberById(int id,vector<User*> &AllMembers)
{
for(auto x:AllMembers)
{
if(x->get_userId()==id)
return x;
}
return nullptr;
}
void Owner::ViewAllBook(vector<Book*> &arr)
{
for(auto x:arr)
{
x->DisplayDetsils();
}
}
void Owner::ViewAllMembers(vector<User*> &mem)
{
for(auto x:mem)
x->ViewInformation();
}
void Owner::IssueBook(Book &h1,Member &mem,vector<Book*> &arr)
{
RemoveBook(arr,h1.get_BookISBN(),"hardcopy");
mem.set_BorrowedBook(&h1);//----set book in member's borrowed book list
cout<<endl<<"book issued successfully"<<endl;
}
void Owner::Collect_Book(Member &mem,vector<Book*> &arr)
{
string isbn;
cout<<endl<<"enter the isbn id of book you want to return : ";
cin>>isbn;
BookSearchStrategy *bs=new SearchByIsbn();
Book *b1=mem.search(bs,mem.get_BorrowedBook(),isbn);//---if the book is not borrowed by that member than throw an int instance
if(!b1)
throw 4;
AddBooks(arr,b1->get_Title(),b1->get_AuthorName(),b1->get_price(),b1->get_Publisher(),"hardcopy",b1->get_Edition());
//-----removed the book from the list of borrowed book of that member -------//
int count1=0;
for(auto x:mem.get_BorrowedBook())
{
if(x->get_BookISBN()==b1->get_BookISBN())
mem.get_BorrowedBook().erase(mem.get_BorrowedBook().begin()+count1);
count1++;
}
cout<<endl<<"book collected successfully"<<endl;
}
void Owner::UpdateInformation(vector<Book*> &arr)
{
string isbn;
cout<<endl<<"enter the isbn of book you want to update : ";
cin>>isbn;
BookSearchStrategy *bs=new SearchByIsbn();
Book *b1=search(bs,arr,isbn);
if(b1==nullptr)
throw 5;
int select;
cout<<endl<<"1. update title : ";
cout<<endl<<"2. update author name : ";
cout<<endl<<"3. update publisher name : ";
cout<<endl<<"4. update price : ";
cout<<endl<<"5. Update edition : "<<endl;
cout<<endl<<"please select what you want to delete : ";
cin>>select;
switch(select)
{
case 1:
{
cout<<endl<<"enter the new title : ";
string title;
cin>>title;
b1->set_Title(title);
break;
}
case 2:
{
cout<<endl<<"enter the new author name : ";
string author_name;
cin>>author_name;
b1->set_AuthorName(author_name);
break;
}
case 3:
{
cout<<endl<<"enter the new publisher : ";
string publisher;
cin>>publisher;
b1->set_Publisher(publisher);
break;
}
case 4:
{
cout<<endl<<"enter the new price : ";
int price;
cin>>price;
b1->set_price(price);
break;
}
case 5:
{
cout<<endl<<"enter the new edition : ";
int edition;
cin>>edition;
break;
}
}
}
//----------------------------------------------------------------------Library--------------------------------------------------------------//
Book* Library::FindBookByISBN(int id)
{
for(auto x:Books)
{
if(x->get_BookISBN()==id)
return x;
}
return nullptr;
}
User* Library::FindMemberById(int id)
{
for(auto x:AllMembers)
{
if(x->get_userId()==id)
return x;
}
return nullptr;
}
void Library::DisplayAllAvailableBooks()
{
cout<<endl<<endl<<"--------- available e books are-----------------"<<endl<<endl;
for(auto x:Books)
x->DisplayDetsils();
}
int main()
{
Library *lib=Library::getInstance();
int option;
while(1)
{
cout<<endl<<"functions in library : "<<endl;
cout<<endl<<"1. RegisterMenber";
cout<<endl<<"2. RemoveMember";
cout<<endl<<"3. DisplayAllAvailableBooks";
cout<<endl<<"4. AddBooks";
cout<<endl<<"5. RemoveBook";
cout<<endl<<"6. ViewAllBooks";
cout<<endl<<"7. ViewAllMembers";
cout<<endl<<"8. IssueBook";
cout<<endl<<"9. CollectBook";
cout<<endl<<"10. UpdateInformation";
cout<<endl<<"11. View detail of specific Book";
cout<<endl<<"12. View Detail of borroewed book by a member";
cout<<endl<<"13. Exit"<<endl;
cout<<endl<<"select option : ";
cin>>option;
switch(option)
{
case 1:
cout << endl<<"Registering member..." << endl;
try{
string name;
cout<<endl<<"enter your name"<<endl;
cin>>name;
lib->o1.RegisterMember(name,lib->AllMembers);
}
catch(int e)
{
if(e==6){cout<<endl<<"A member ia already registered with this id"<<endl;}
}
break;
case 2:
cout << "\nRemoving a member..." << endl;
try{
lib->o1.RemoveMember(lib->AllMembers); // INPUT 5
}
catch(int e)
{
if(e==7){cout<<endl<<"this memeber is not registered with library"<<endl;}
if(e==8){cout<<endl<<"This member borowed some book collect book before to remove"<<endl;}
}
break;
case 3:
cout << "\nViewing all available books..." << endl;
lib->DisplayAllAvailableBooks();
break;
case 4:
cout << "\nAdding an Ebook or a HardCopy book..." << endl;
try{
cout<<endl<<"enter the title : ";
string title;
cin>>title;
cout<<endl<<"enter the author name : ";
string author;
cin>>author;
cout<<endl<<"enter the new publisher : ";
string publisher;
cin>>publisher;
cout<<endl<<"enter the new price : ";
double price;
cin>>price;
cout<<endl<<"enter the type of book : ";
string type;
cin>>type;
cout<<endl<<"enter the new edition : ";
int edition;
cin>>edition;
string link="";
if(type=="Ebook"){
cout<<endl<<"enter the link : ";
cin>>link;
}
lib->o1.AddBooks(lib->Books,title,author,price,publisher,type,edition,link);
}
catch(int e)
{
if(e==2){cout<<endl<<"A book is already present in library with this id"<<endl;}
}
break;
case 5:
{
cout << "\nRemoving a book by ISBN..." << endl;
int removeISBN;
cout << "Enter ISBN to remove: ";
cin >> removeISBN;
string type;
cout<<endl<<"enter teh type of books : ";
cin>>type;
lib->o1.RemoveBook(lib->Books, removeISBN,type);
break;
}
case 6:
lib->o1.ViewAllBook(lib->Books);
break;
case 7:
cout << "\nViewing all registered members..." << endl;
lib->o1.ViewAllMembers(lib->AllMembers);
break;
case 8:
{
cout << "\nIssuing a hard copy book to a member..." << endl;
int hardCopyISBN;
cout <<endl<<"Enter ISBN of the hardcopy book to issue: ";