-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcs253Assgn_code.cpp
More file actions
2141 lines (1893 loc) · 57.7 KB
/
Copy pathcs253Assgn_code.cpp
File metadata and controls
2141 lines (1893 loc) · 57.7 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
/**************************************************************************
*
*-------------------- LIBRARY MANAGEMENT SYSTEM --------------------------
*
* This program implements a Library Management System in C++ using OOP
* concepts (abstraction, inheritance, polymorphism, encapsulation).
* It manages books and users (Students, Faculty, and Librarians) and
* supports operations such as borrowing, returning, reserving books,
* fine management, and administrative functions for the librarian.
*
* Students: Can borrow up to 3 books for 15 days max. Overdue books
* incur a fine of 10 rupees per extra day. The overdue fine is
* shown in account details until paid; when paying the fine,
* the overdue count resets to zero.
*
* Faculty: Can borrow up to 5 books for 30 days max. They incur no fine,
* but if any borrowed book is overdue by more than 60 days, further
* borrowing is blocked.
*
* Librarians: Can manage the library (add, remove, update books and users)
* but cannot borrow or reserve books.
*
* Note: There are three default librarians with the following credentials (username/password):
* librarian1 / admin1, librarian2 / admin2, and librarian3 / admin3.
*
* Each Book record (representing one copy) displays:
* Book ID, Title, Publisher, Year, ISBN, and a computed Status.
* Computed Status (determined at view time) is:
* "Available" if not borrowed;
* "Borrowed" if borrowed by the current user;
* "Reserved" if reserved by someone else and
* (shows "Reserved (For You)" if reserved by the current user).
*
* Default data consists of 10 titles with 5 copies each (50 records total).
* Each copy is assigned a unique Book ID.
*
* Data is persisted immediately to files: books.txt, users.txt, and
* transactions.txt.
*
* Compile with: g++ -std=c++11 cs253Assgn.cpp -o cs253Assgn
* Run with: ./cs253Assgn
*
**************************************************************************/
// ========== Standard Library Includes ==========
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <limits>
#include <ctime>
#include <cstdlib>
#include <iomanip>
#include <cctype>
using namespace std;
// ========== Utility Functions ==========
// Function: trim()
// Removes leading and trailing whitespace from a string.
string trim(const string & s)
{
auto start = s.begin();
while (start != s.end() && isspace(*start))
{
start++;
}
auto end = s.end();
if (start != s.end())
{
do
{
end--;
}
while (distance(start, end) > 0 && isspace(*end));
}
return string(start, end + 1);
}
// Function: getTimeString()
// Converts a time_t value to a human-readable string using ctime().
// Also removes the trailing newline character.
string getTimeString(time_t t)
{
char * dt = ctime(&t);
string s(dt);
if (!s.empty() && s.back() == '\n')
{
s.pop_back();
}
return s;
}
// ========== Enumeration and Conversion Functions ==========
// Enumeration: BookStatus
enum class BookStatus
{
Available,
Borrowed,
Reserved
};
// Function: statusToString()
// Converts a BookStatus enum value to its string representation.
string statusToString(BookStatus status)
{
switch (status)
{
case BookStatus::Available:
{
return "Available";
}
case BookStatus::Borrowed:
{
return "Borrowed";
}
case BookStatus::Reserved:
{
return "Reserved";
}
}
return "Unknown";
}
// Function: stringToStatus()
// Converts a string to a BookStatus enum value.
BookStatus stringToStatus(const string & str)
{
if (str == "Available")
{
return BookStatus::Available;
}
if (str == "Borrowed")
{
return BookStatus::Borrowed;
}
if (str == "Reserved")
{
return BookStatus::Reserved;
}
return BookStatus::Available;
}
// ========== Class Definitions ==========
// Class: Book
// Represents one copy of a book in the library.
// (Only computed status is shown when viewing details.)
class Book
{
private:
int id;
string title;
string author; // Not displayed.
string publisher;
int year;
string ISBN;
BookStatus status;
int borrowedBy; // 0 if not borrowed.
int reservedBy; // 0 if not reserved.
public:
// Default constructor.
Book()
: id(0)
, title("")
, author("")
, publisher("")
, year(0)
, ISBN("")
, status(BookStatus::Available)
, borrowedBy(0)
, reservedBy(0)
{
}
// Parameterized constructor.
Book(int id, const string & title, const string & author, const string & publisher, int year, const string & ISBN, BookStatus status = BookStatus::Available)
: id(id)
, title(title)
, author(author)
, publisher(publisher)
, year(year)
, ISBN(ISBN)
, status(status)
, borrowedBy(0)
, reservedBy(0)
{
}
// Getter methods.
int getId() const
{
return id;
}
string getTitle() const
{
return title;
}
string getPublisher() const
{
return publisher;
}
int getYear() const
{
return year;
}
string getISBN() const
{
return ISBN;
}
BookStatus getStatus() const
{
return status;
}
int getBorrowedBy() const
{
return borrowedBy;
}
int getReservedBy() const
{
return reservedBy;
}
// Update methods.
void updateTitle(const string & newTitle)
{
title = newTitle;
}
void updateAuthor(const string & newAuthor)
{
author = newAuthor;
}
void updatePublisher(const string & newPublisher)
{
publisher = newPublisher;
}
void updateYear(int newYear)
{
year = newYear;
}
void updateISBN(const string & newISBN)
{
ISBN = newISBN;
}
void updateStatus(BookStatus newStatus)
{
status = newStatus;
}
void updateBorrowedBy(int userId)
{
borrowedBy = userId;
}
void updateReservedBy(int userId)
{
reservedBy = userId;
}
// Prints book details (without stored status).
void printDetails() const
{
cout << "---------------------------------------" << endl;
cout << "Book ID: " << id << endl;
cout << "Title: " << title << endl;
cout << "Publisher: " << publisher << endl;
cout << "Year: " << year << endl;
cout << "ISBN: " << ISBN << endl;
cout << "---------------------------------------" << endl;
}
// Serializes book data.
string serialize() const
{
ostringstream oss;
oss << id << ";" << title << ";" << author << ";" << publisher << ";"
<< year << ";" << ISBN << ";" << statusToString(status) << ";"
<< borrowedBy << ";" << reservedBy;
return oss.str();
}
// Deserializes book data.
void deserialize(const string & data)
{
try
{
istringstream iss(data);
string token;
getline(iss, token, ';');
id = stoi(token);
getline(iss, title, ';');
getline(iss, author, ';');
getline(iss, publisher, ';');
getline(iss, token, ';');
year = stoi(token);
getline(iss, ISBN, ';');
getline(iss, token, ';');
status = stringToStatus(token);
getline(iss, token, ';');
borrowedBy = stoi(token);
getline(iss, token, ';');
reservedBy = stoi(token);
}
catch (exception & e)
{
id = 0;
title = "";
author = "";
publisher = "";
year = 0;
ISBN = "";
status = BookStatus::Available;
borrowedBy = 0;
reservedBy = 0;
}
}
};
// Class: BorrowRecord
// Stores a borrow record.
struct BorrowRecord
{
int bookId;
time_t borrowTimestamp;
int borrowDays;
};
// Class: Account
// Manages borrow records and fines.
class Account
{
private:
vector<BorrowRecord> borrowRecords;
double fineDue;
public:
// Default constructor.
Account()
: fineDue(0.0)
{
}
// Returns borrow records.
vector<BorrowRecord> getBorrowRecords() const
{
return borrowRecords;
}
// Returns current fine.
double getFine() const
{
return fineDue;
}
// Adds a new borrow record.
void addBorrowedBook(int bookId, int borrowDays)
{
BorrowRecord record;
record.bookId = bookId;
record.borrowTimestamp = time(0);
record.borrowDays = borrowDays;
borrowRecords.push_back(record);
}
// Removes a borrow record.
void removeBorrowedBook(int bookId)
{
auto it = remove_if(borrowRecords.begin(), borrowRecords.end(),
[bookId](const BorrowRecord & r)
{
return r.bookId == bookId;
}
);
if (it != borrowRecords.end())
{
borrowRecords.erase(it, borrowRecords.end());
}
}
// Adds a fine.
void addFine(double fine)
{
fineDue += fine;
}
// Resets the fine amount.
void resetFine()
{
fineDue = 0;
}
// Resets borrow timestamps to current time.
void resetBorrowTimestamps()
{
time_t now = time(0);
for (auto & record : borrowRecords)
{
record.borrowTimestamp = now;
}
}
// Prints account details.
void printAccountDetails() const
{
cout << "Borrowed Books:" << endl;
time_t now = time(0);
bool nonOverdueFound = false;
for (const auto & record : borrowRecords)
{
int daysElapsed = static_cast<int>(difftime(now, record.borrowTimestamp) / 86400);
if (daysElapsed <= record.borrowDays)
{
cout << "Book ID: " << record.bookId
<< ", Borrow Date: " << getTimeString(record.borrowTimestamp)
<< ", Intended Borrow Days: " << record.borrowDays
<< ", Days Elapsed: " << daysElapsed << endl;
nonOverdueFound = true;
}
}
if (!nonOverdueFound)
{
cout << "No currently borrowed (non-overdue) books." << endl;
}
cout << "\nOverdue Books:" << endl;
bool overdueFound = false;
for (const auto & record : borrowRecords)
{
int daysElapsed = static_cast<int>(difftime(now, record.borrowTimestamp) / 86400);
if (daysElapsed > record.borrowDays)
{
cout << "Book ID: " << record.bookId
<< ", Borrow Date: " << getTimeString(record.borrowTimestamp)
<< ", Intended Borrow Days: " << record.borrowDays
<< ", Days Elapsed: " << daysElapsed << endl;
overdueFound = true;
}
}
if (!overdueFound)
{
cout << "No overdue books." << endl;
}
cout << "Fine Due: " << fineDue << " rupees" << endl;
}
// Serializes account data.
string serialize() const
{
ostringstream oss;
oss << fineDue;
for (const auto & record : borrowRecords)
{
oss << ";" << record.bookId << "," << record.borrowTimestamp << "," << record.borrowDays;
}
return oss.str();
}
// Deserializes account data.
void deserialize(const string & data)
{
borrowRecords.clear();
try
{
istringstream iss(data);
string token;
getline(iss, token, ';');
fineDue = stod(token);
while (getline(iss, token, ';'))
{
istringstream recordStream(token);
BorrowRecord record;
string part;
getline(recordStream, part, ',');
record.bookId = stoi(part);
getline(recordStream, part, ',');
record.borrowTimestamp = static_cast<time_t>(stoll(part));
getline(recordStream, part, ',');
record.borrowDays = stoi(part);
borrowRecords.push_back(record);
}
}
catch (exception & e)
{
borrowRecords.clear();
fineDue = 0;
}
}
};
// ========== Forward Declarations ==========
class Library; // Forward declaration of Library for use in User display.
// ========== Class: User ==========
class User
{
protected:
int userId;
string username;
string password;
Account account;
public:
// Default constructor.
User()
: userId(0)
, username("")
, password("")
{
}
// Parameterized constructor.
User(int id, const string & uname, const string & pwd)
: userId(id)
, username(uname)
, password(pwd)
{
}
virtual ~User()
{
}
int getUserId() const
{
return userId;
}
string getUsername() const
{
return username;
}
bool checkPassword(const string & pwd) const
{
return password == pwd;
}
Account & getAccount()
{
return account;
}
// Declaration: Display user details, account info, and reserved books.
virtual void display(const Library & lib) const;
// Pure virtual functions for borrowing and returning books.
virtual void borrowBook(Library & lib) = 0;
virtual void returnBook(Library & lib) = 0;
// Serializes user data.
virtual string serialize() const
{
ostringstream oss;
oss << userId << ";" << username << ";" << password << ";" << account.serialize();
return oss.str();
}
// Deserializes user data.
virtual void deserialize(const string & data)
{
istringstream iss(data);
string token;
getline(iss, token, ';');
userId = stoi(token);
getline(iss, username, ';');
username = trim(username);
getline(iss, password, ';');
password = trim(password);
string accData;
getline(iss, accData);
account.deserialize(accData);
}
// Setters.
void setUsername(const string & uname)
{
username = uname;
}
void setPassword(const string & pwd)
{
password = pwd;
}
};
// ========== Class: Student ==========
class Student : public User
{
private:
int maxBooks; // 3 books maximum.
int maxDays; // 15 days maximum.
double fineRate; // 10 rupees per overdue day.
public:
// Default constructor.
Student()
: User()
, maxBooks(3)
, maxDays(15)
, fineRate(10.0)
{
}
// Parameterized constructor.
Student(int id, const string & uname, const string & pwd)
: User(id, uname, pwd)
, maxBooks(3)
, maxDays(15)
, fineRate(10.0)
{
}
virtual void borrowBook(Library & lib) override;
virtual void returnBook(Library & lib) override;
// Function to reserve a book.
void reserveBook(Library & lib);
// Declaration: Display student details along with computed fine and reserved books.
virtual void display(const Library & lib) const override;
};
// ========== Class: Faculty ==========
class Faculty : public User
{
private:
int maxBooks; // 5 books maximum.
int maxDays; // 30 days maximum.
public:
// Default constructor.
Faculty()
: User()
, maxBooks(5)
, maxDays(30)
{
}
// Parameterized constructor.
Faculty(int id, const string & uname, const string & pwd)
: User(id, uname, pwd)
, maxBooks(5)
, maxDays(30)
{
}
virtual void borrowBook(Library & lib) override;
virtual void returnBook(Library & lib) override;
void reserveBook(Library & lib);
// Declaration: Display faculty details.
virtual void display(const Library & lib) const override;
};
// ========== Class: Librarian ==========
class Librarian : public User
{
public:
// Default constructor.
Librarian()
: User()
{
}
// Parameterized constructor.
Librarian(int id, const string & uname, const string & pwd)
: User(id, uname, pwd)
{
}
virtual void borrowBook(Library & lib) override
{
cout << "Librarian cannot borrow books." << endl;
}
virtual void returnBook(Library & lib) override
{
cout << "Librarian does not return books." << endl;
}
// Declaration: Display librarian details.
virtual void display(const Library & lib) const override;
// Administrative functions.
void addBook(Library & lib);
void removeBook(Library & lib);
void updateBook(Library & lib);
void addUser(Library & lib);
void removeUser(Library & lib);
void updateUser(Library & lib);
};
// ========== Forward Declarations for Portal Menus ==========
void userPortalMenu(User * user, Library & lib);
void librarianPortalMenu(Librarian * libUser, Library & lib);
// ========== Class: Library ==========
class Library
{
private:
vector<Book> books; // Collection of books.
vector<User*> users; // Collection of users.
vector<string> transactionLog;
const string booksFile = "books.txt";
const string usersFile = "users.txt";
const string logFile = "transactions.txt";
// Loads default book data.
void loadDefaultBooks()
{
books.clear();
vector<tuple<string, string, string, int, string>> defaultTitles = {
make_tuple("The C++ Programming Language", "Bjarne Stroustrup", "Addison-Wesley", 2013, "9780321563842"),
make_tuple("Effective C++", "Scott Meyers", "O'Reilly", 2005, "9780321334879"),
make_tuple("Clean Code", "Robert C. Martin", "Prentice Hall", 2008, "9780132350884"),
make_tuple("Design Patterns", "Erich Gamma et al.", "Addison-Wesley", 1994, "9780201633610"),
make_tuple("Modern Operating Systems", "Andrew Tanenbaum", "Pearson", 2014, "9780133591620"),
make_tuple("Introduction to Algorithms", "Cormen et al.", "MIT Press", 2009, "9780262033848"),
make_tuple("Artificial Intelligence: A Modern Approach", "Stuart Russell", "Pearson", 2009, "9780136042594"),
make_tuple("The Pragmatic Programmer", "Andrew Hunt", "Addison-Wesley", 1999, "9780201616224"),
make_tuple("Code Complete", "Steve McConnell", "Microsoft Press", 2004, "9780735619678"),
make_tuple("Refactoring", "Martin Fowler", "Addison-Wesley", 1999, "9780201485677")
};
int newId = 1;
for (auto & tpl : defaultTitles)
{
for (int i = 0; i < 5; i++)
{
Book book(newId, get<0>(tpl), get<1>(tpl), get<2>(tpl), get<3>(tpl), get<4>(tpl), BookStatus::Available);
books.push_back(book);
newId++;
}
}
}
public:
// Constructor: Loads books, users, and transaction log.
Library()
{
loadBooks();
loadUsers();
loadTransactionLog();
}
// Destructor: Saves data and cleans up.
~Library()
{
saveBooks();
saveUsers();
saveTransactionLog();
for (auto user : users)
{
delete user;
}
}
// Loads books from file or defaults.
void loadBooks()
{
books.clear();
ifstream fin(booksFile);
if (!fin || fin.peek() == ifstream::traits_type::eof())
{
cout << "Books file not found or empty. Loading default books." << endl;
loadDefaultBooks();
return;
}
string line;
vector<Book> tempBooks;
while (getline(fin, line))
{
if (line.empty())
{
continue;
}
Book book;
book.deserialize(line);
tempBooks.push_back(book);
}
fin.close();
if (tempBooks.empty() || tempBooks[0].getTitle().empty())
{
cout << "Books file data invalid. Loading default books." << endl;
loadDefaultBooks();
}
else
{
books = tempBooks;
}
}
// Saves books to file.
void saveBooks()
{
ofstream fout(booksFile);
for (auto & book : books)
{
fout << book.serialize() << "\n";
}
fout.close();
}
// Returns all reserved books for a given user.
vector<Book> getReservedBooksByUser(int userId) const
{
vector<Book> reservedBooks;
for (const auto & book : books)
{
if (book.getReservedBy() == userId)
{
reservedBooks.push_back(book);
}
}
return reservedBooks;
}
// Prints book list with computed status.
void printBooksForUser(int currentUserId) const
{
cout << "\n********** Books List **********\n";
for (const auto & book : books)
{
cout << "---------------------------------------" << endl;
cout << "Book ID: " << book.getId() << endl;
cout << "Title: " << book.getTitle() << endl;
cout << "Publisher: " << book.getPublisher() << endl;
cout << "Year: " << book.getYear() << endl;
cout << "ISBN: " << book.getISBN() << endl;
cout << "Status: ";
if (book.getBorrowedBy() == 0)
{
cout << "Available";
}
else if (book.getBorrowedBy() == currentUserId)
{
cout << "Borrowed";
}
else if (book.getReservedBy() != 0)
{
if (book.getReservedBy() == currentUserId)
{
cout << "Reserved (For You)";
}
else
{
cout << "Reserved";
}
}
else
{
cout << "Borrowed";
}
cout << "\n---------------------------------------\n";
}
}
// Prints books currently borrowed by a user.
void printBorrowedBooksByUser(User * user) const
{
cout << "\n********** Your Borrowed Books **********\n";
vector<BorrowRecord> records = user->getAccount().getBorrowRecords();
bool found = false;
for (const auto & record : records)
{
for (const auto & book : books)
{
if (book.getId() == record.bookId)
{
book.printDetails();
cout << "Borrow Date: " << getTimeString(record.borrowTimestamp)
<< ", Intended Borrow Days: " << record.borrowDays << endl;
found = true;
}
}
}
if (!found)
{
cout << "You have not borrowed any books." << endl;
}
}
// Loads users from file or default data.
void loadUsers()
{
for (auto user : users)
{
delete user;
}
users.clear();
ifstream fin(usersFile);
if (!fin || fin.peek() == ifstream::traits_type::eof())
{
cout << "Users file not found or empty. Loading default users." << endl;
users.push_back(new Student(1, "alice", "pass1"));
users.push_back(new Student(2, "bob", "pass2"));
users.push_back(new Student(3, "charlie", "pass3"));
users.push_back(new Student(4, "diana", "pass4"));
users.push_back(new Student(5, "eric", "pass5"));
users.push_back(new Faculty(6, "profX", "pass6"));
users.push_back(new Faculty(7, "drY", "pass7"));
users.push_back(new Faculty(8, "mrZ", "pass8"));
// Modified default librarians: three librarians with specified credentials.
users.push_back(new Librarian(9, "librarian1", "admin1"));
users.push_back(new Librarian(10, "librarian2", "admin2"));
users.push_back(new Librarian(11, "librarian3", "admin3"));