-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataBase.h
34 lines (31 loc) · 1.01 KB
/
DataBase.h
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
//实现txt数据库, LibrarySystem library1("libary_db3.txt")中libary_db3.txt为数据库路径,实现一个类多个数据库。
#include <string>
struct Book {
std::string bookName;
std::string authorName;
int year;
int quantity;
int bookId;
};
class LibrarySystem {
public:
LibrarySystem(const std::string& path);
void addBook(const std::string& bookName, const std::string& authorName, int quantity, int year); //Change the structure
void removeBook(const int& bookID);
// void removeBook(const string& bookName);
// void returnBook(const string& bookName);
void returnBook(const int& bookID);
void searchBook(const std::string& bookName);
void printDatabase(); //Change the structure
void clearDatabase();
Book* findBookById(int bookId);
Book* getBooks();
int getNumBooks();
private:
std::string databaseFileName;
int numBooks;
Book* books;
int getNextBookId();
void loadDatabase();//Change the structure
void saveDatabase();// //Change the structure
};