Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- class Book {
- private:
- string name;
- vector<string> authors;
- string dateTaken;
- public:
- Book(string name, string author, string date) {
- this->name = name;
- this->authors.push_back(author);
- this->dateTaken = date;
- }
- Book(string name, vector<string> authors, string date) {
- this->name = name;
- this->dateTaken = date;
- this->authors.insert(this->authors.end(), authors.begin(), authors.end());
- }
- string getName() const { return this->name; }
- string getDateTaken() const { return this->dateTaken; }
- vector<string> getAuthors() const { return this->authors; }
- friend ostream& operator<<(ostream& os, const Book& book);
- };
- ostream &operator<<(ostream &os, const Book& book) {
- os << "Book name: " << book.getName() << "\n";
- return os;
- }
- class Library {
- private:
- int bookCount;
- vector<Book> books;
- public:
- void addBook(const Book& book) {
- bookCount++;
- this->books.push_back(book);
- }
- void addBooks(vector<Book> booksVector) {
- bookCount += booksVector.size();
- this->books.insert(this->books.end(), booksVector.begin(), booksVector.end());
- }
- vector<Book> filterByDateTaken(const string& date) {
- vector<Book> takenBooks;
- for (auto & book : this->books) {
- if (book.getDateTaken() == date) {
- takenBooks.push_back(book);
- }
- }
- return takenBooks;
- }
- };
- int main() {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement