-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLibrary.cpp
107 lines (89 loc) · 1.81 KB
/
Library.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
//
// Library.cpp
// Library Project
//
// Created by Ronak Lamba on 1/8/25.
//
#include "Library.h"
void Library::addBook(const Book& book)
{
books[book.getBookISBN()] = book;
}
void Library::addMember(const Member& member)
{
members[member.getMemberIDNumber()] = member;
}
Book* Library::findBookByISBN(const string& isbn)
{
auto it = books.find(isbn);
if (it != books.end())
{
return &(it->second);
}
return nullptr;
}
Member* Library::findMemberByIDNumber(const string& idNumber)
{
auto it = members.find(idNumber);
if (it != members.end())
{
return &(it->second);
}
return nullptr;
}
void Library::displayAllBooks(ostream& out) const
{
if (books.empty())
{
out << "No books available in the library. " << endl;
}
else
{
for (const auto& pair : books)
{
pair.second.displayBook(out);
}
}
}
void Library::displayAllMembers(ostream& out) const
{
if (members.empty())
{
out << "No members registered with the library. " << endl;
}
else
{
for (const auto& pair : members)
{
pair.second.displayMember(out);
}
}
}
void Library::displayAllBooksWithDetails(ostream& out) const
{
if (books.empty())
{
out << "No books available in the library. " << endl;
}
else
{
for (const auto& pair : books)
{
pair.second.displayBookInfo(out);
}
}
}
void Library::displayAllMembersWithDetails(ostream& out) const
{
if (members.empty())
{
out << "No members registred with the library. " << endl;
}
else
{
for (const auto& pair : members)
{
pair.second.displayMemberInfo(out);
}
}
}