Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <unordered_map>
- #include <iostream>
- #include <utility> // todo figure out what this iostream
- #include "Book.h"
- using namespace std;
- class Library {
- public: // member access specifier
- // attributes
- int available_books;
- string address;
- unordered_map<string, Book> books; // mapping from isbn (string) -> book (Book)
- // methods
- Library(); // constructor
- void insertBook(string, Book);
- int getAvailableBooks();
- void printLibrary();
- };
- Library::Library() {
- available_books = 0;
- address = "";
- }
- void Library::insertBook(string key, Book value) {
- pair<string,Book> bookToInsert (key, value);
- books.insert(bookToInsert);
- this->available_books++;
- }
- int Library::getAvailableBooks() {
- return this->available_books;
- }
- void Library::printLibrary() {
- // look up how to either
- // iterate hashmap -- they've probably got this function
- // or make a list of my keys and iterate through that, calling each key
- this->books["1234"].printBook();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement