-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
172 lines (132 loc) · 3.01 KB
/
Copy pathmain.cpp
File metadata and controls
172 lines (132 loc) · 3.01 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
#include <iostream>
#include "Library.h"
using namespace std;
int main()
{
Library library;
library.loadBooks();
library.loadMembers();
library.loadTransactions();
int choice;
while (true)
{
cout << "\n========== LIBRARY MANAGEMENT SYSTEM ==========\n";
cout << "1. Add Book\n";
cout << "2. Search Book\n";
cout << "3. Delete Book\n";
cout << "4. Display All Books\n";
cout << "5. Add Member\n";
cout << "6. Search Member\n";
cout << "7. Display All Members\n";
cout << "8. Issue Book\n";
cout << "9. Return Book\n";
cout << "10. Display Transactions\n";
cout << "11. Exit\n";
cout << "\nEnter your choice: ";
cin >> choice;
switch(choice)
{
case 1:
{
int id;
string title;
string author;
cout << "Enter Book ID: ";
cin >> id;
cin.ignore();
cout << "Enter Title: ";
getline(cin, title);
cout << "Enter Author: ";
getline(cin, author);
Book book(id, title, author);
library.addBook(book);
cout << "Book added successfully.\n";
break;
}
case 2:
{
int id;
cout << "Enter Book ID: ";
cin >> id;
library.searchBook(id);
break;
}
case 3:
{
int id;
cout << "Enter Book ID: ";
cin >> id;
library.deleteBook(id);
break;
}
case 4:
{
library.displayAllBooks();
break;
}
case 5:
{
int id;
string name;
string email;
cout << "Enter Member ID: ";
cin >> id;
cin.ignore();
cout << "Enter Member Name: ";
getline(cin, name);
cout << "Enter Email: ";
getline(cin, email);
Member member(id, name, email);
library.addMember(member);
cout << "Member added successfully.\n";
break;
}
case 6:
{
int id;
cout << "Enter Member ID: ";
cin >> id;
library.searchMember(id);
break;
}
case 7:
{
library.displayAllMembers();
break;
}
case 8:
{
int bookId;
int memberId;
string issueDate;
cout << "Enter Book ID: ";
cin >> bookId;
cout << "Enter Member ID: ";
cin >> memberId;
cin.ignore();
cout << "Enter Issue Date: ";
getline(cin, issueDate);
library.issueBook(bookId, memberId, issueDate);
break;
}
case 9:
{
int transactionId;
cout << "Enter Transaction ID: ";
cin >> transactionId;
library.returnBook(transactionId);
break;
}
case 10:
{
library.displayAllTransactions();
break;
}
case 11:
cout << "Thank you for using the Library Management System!\n";
return 0;
default:
cout << "Invalid Choice!\n";
}
}
}