Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <string>
  2. #include <unordered_map>
  3. #include <iostream>
  4. #include <utility> // todo figure out what this iostream
  5.  
  6. #include "Book.h"
  7.  
  8. using namespace std;
  9.  
  10. class Library {
  11. public: // member access specifier
  12. // attributes
  13. int available_books;
  14. string address;
  15. unordered_map<string, Book> books; // mapping from isbn (string) -> book (Book)
  16.  
  17.  
  18. // methods
  19. Library(); // constructor
  20. void insertBook(string, Book);
  21. int getAvailableBooks();
  22. void printLibrary();
  23. };
  24.  
  25. Library::Library() {
  26. available_books = 0;
  27. address = "";
  28. }
  29.  
  30. void Library::insertBook(string key, Book value) {
  31. pair<string,Book> bookToInsert (key, value);
  32. books.insert(bookToInsert);
  33. this->available_books++;
  34. }
  35.  
  36. int Library::getAvailableBooks() {
  37. return this->available_books;
  38. }
  39.  
  40. void Library::printLibrary() {
  41. // look up how to either
  42. // iterate hashmap -- they've probably got this function
  43. // or make a list of my keys and iterate through that, calling each key
  44. this->books["1234"].printBook();
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement