This repository was archived by the owner on Dec 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibrary.h
More file actions
88 lines (73 loc) · 2.45 KB
/
Library.h
File metadata and controls
88 lines (73 loc) · 2.45 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef LIBRARY_H
#define LIBRARY_H
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <map>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include "Book.h"
#include "User.h"
class Library{
public:
//Two methods of checking out book
//One is from file input, uses vector for data
//Other is from command line, uses userID and bookID
void checkout(vector<string> bookInfo);
void checkout (int userID, int bookID);
//Returns single book given bookID
void returnBook(int id);
//Given User or Book, adds it to Library
void addUser(User *aUser);
void addBook(Book *aBook);
//Prints specific Book or User information
void PrintLibraryBook(int id) const;
void PrintLibraryUser(int id) const;
//Prints an update about the Library status
void PrintSystem() const;
//Checks if Books or Accounts is empty
bool isBooksEmpty(){return idLib.empty();}
bool isAccountsEmpty(){return userLib.empty();}
//Converts the file input data into int
//So that it can be stored correctly
std::vector<int> convertToInt(std::vector<std::string> input);
//Creates new ID for Book or User
int getNewID(){return usedBookIDs.size()+1;}
int getNewUserID(){return usedUserIDs.size()+1;}
//Provided ID's, deleted Book or User
void removeBook(int id);
void removeUser(int id);
//Account and User ID
//Can be printed in order
void sortByAccountID();
void sortByBookID();
//Search Book for titles/authors with searchWord
void searchTitles(string searchWord);
void searchAuthors(string searchPhrase);
//Renew all eligible Books in User
void renewUsersBook(int id);
//Determines which sort method to use
void sortDataBy(string sortBy);
//Determines if Book can be added or if Book already exists
bool bookTitleAuthorExists(string title, string author);
//Dont work yet..
void exportLib(string bookFile, string accountFile);
void makeRecs(int id);
private:
void PrintSortedBook(vector<Book*>& sortedBooks) const;
void PrintSortedUser(vector<User*>& sortedUsers) const;
int numBooks;
int numUsers;
//Keeps track of all Books and Users
//According to their unique ID
std::map <int, Book*> idLib;
std::map <int, User*> userLib;
std::unordered_set<int> usedBookIDs; //keeps track of all book IDs
std::unordered_set<int> usedUserIDs;//keeps track of all user IDs
//Calculate number of overdue books/accounts
int numOverDueBooks() const;
int numOverDueAccounts() const;
};
#endif