Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Book {
- private:
- string isbn;
- string author;
- string title;
- string year;
- string publisher;
- string page_count;
- //friend auto BookList::search_by_author(string);
- public:
- Book(string _isbn, string _author, string _title, string _year, string _publisher, string _page_count) {
- isbn = _isbn;
- author = _author;
- title = _title;
- year = _year;
- publisher = _publisher;
- page_count = _page_count;
- }
- auto serialize() {
- auto s = isbn + "^^^" + author + "^^^" + title + "^^^" + year + "^^^" + publisher + "^^^" + page_count;
- return s;
- }
- };
- class BookList {
- private:
- vector<Book> list;
- public:
- auto add(string isbn, string author, string title, string year, string publisher, string page_count) {
- list.emplace_back(isbn, author, title, year, publisher, page_count);
- return;
- }
- auto search_by_author(string author) {
- vector<Book> matches;
- for (auto book : list)
- /*if (book.author == author)
- matches.push_back(book);*/
- return matches;
- }
- auto serialize(vector<Book> entries) {
- vector<string> serialized;
- for (auto entry : entries)
- serialized.push_back(entry.serialize());
- return serialized;
- }
- } books;
Advertisement
Add Comment
Please, Sign In to add comment