-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (39 loc) · 1.3 KB
/
main.cpp
File metadata and controls
47 lines (39 loc) · 1.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
void saveBooks(const std::vector<Book>& books) {
std::ofstream file("books.txt");
for (const auto& book : books) {
file << book.bookID << "," << book.title << "," << book.author << "," << book.genre << "," << book.status << "\n";
}
file.close();
}
void loadBooks(std::vector<Book>& books) {
std::ifstream file("books.txt");
std::string line;
while (std::getline(file, line)) {
std::stringstream ss(line);
std::string id, title, author, genre, status;
std::getline(ss, id, ',');
std::getline(ss, title, ',');
std::getline(ss, author, ',');
std::getline(ss, genre, ',');
std::getline(ss, status, ',');
books.emplace_back(std::stoi(id), title, author, genre, status);
}
file.close();
}
int main() {
std::vector<Book> books;
std::vector<Member> members;
std::vector<Transaction> transactions;
// Load data from files
loadBooks(books);
// Example usage
books.emplace_back(1, "The Great Gatsby", "F. Scott Fitzgerald", "Fiction", "Available");
saveBooks(books);
// Display all available books
reportAvailableBooks(books);
// Display all borrowed books
reportBorrowedBooks(books);
// Display overdue members
displayOverdueMembers(transactions, members);
return 0;
}