-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbox.cpp
More file actions
37 lines (26 loc) · 674 Bytes
/
box.cpp
File metadata and controls
37 lines (26 loc) · 674 Bytes
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
#include <iostream>
#include "box.h"
#include <map>
#include <sstream>
using namespace std;
void Box::add_book(Book &book) {
int bookId = book.get_id();
books.insert(map<unsigned int, Book>::value_type(bookId, book));
}
void Box::delete_book(unsigned int id) {
auto it = books.find(id);
if (it != books.end()) {
books.erase(it);
} else {
cout << "This book does not exist" << endl;
}
}
Book &Box::get_book(unsigned int id) {
return books.find(id)->second;
}
const map<unsigned int, Book> &Box::get_books() const {
return books;
}
bool Box::has_book_id(unsigned int id) {
return books.find(id) != books.end();
}