-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLibrary.h
More file actions
137 lines (115 loc) · 2.59 KB
/
Copy pathLibrary.h
File metadata and controls
137 lines (115 loc) · 2.59 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/**
* @file Library.h
* @author Sam Emison + Cole Belew
* @date 2024-11-08
* @brief Class file for library
*
* Holds all of the functions for Library
*/
#ifndef LIBRARY_H
#define LIBRARY_H
#include <string>
#include <iostream>
struct Book {
std::string title;
std::string author;
std::string isbn;
int pages;
float price;
int year;
Book* next;
//Constructor to initialize a Book
Book(const std::string &title, const std::string &author, const std::string &isbn, int pages, float price, int year, Book* next = nullptr)
: title(title), author(author), isbn(isbn), pages(pages), price(price), year(year), next(next) {}
};
/**
* Contains the class and the functions for the library. How it works
*
* @class Library Library.h "Library/Library.h"
* @brief
*
*/
class Library {
private:
Book* head;
public:
Library(); //Constructor
~Library(); //Destructor
//Functionality to manage the books
/**
* Inserts the books into a sorted order by last name
*
* @param const std::string &title
* @param const std::string &author
* @param const std::string &isbn
* @param int pages
* @param float price
* @param int year
* @pre
* @return void
* @post
*
*/
void insert_sorted(const std::string &title, const std::string &author, const std::string &isbn, int pages, float price, int year);
/**
* Finds the title based on via author name
*
* @param const std::string &title
* @pre
* @return void
* @post Returns the authors name
*
*/
void find_album(const std::string &title) const;
/**
* Finds the authors name via title of the book
*
* @param const std::string &author
* @pre
* @return void
* @post Returns the authors name
*
*/
void find_author(const std::string &author) const;
/**
* Deletes a book from the selection
*
* @param const std::string &author
* @param const std::string &title
* @pre
* @return bool
* @post Book is deleted
*
*/
bool deleteBook(const std::string &author, const std::string &title);
/**
* Writes the list of books to a file
*
* @param const std::string &filename
* @pre
* @return bool
* @post Writes to file of users choice
*
*/
bool write_to_file(const std::string &filename) const;
/**
* Reads books from a file and adds them into the sort
*
* @param const std::string &filename
* @pre
* @return bool
* @post Takes in the data from the file and adds it its list
*
*/
bool read_from_file(const std::string &filename);
/**
* Prints the list into the terminal
*
* @pre
* @return void
* @post Prints the list
*
*/
void print() const;
};
#endif //LIBRARY_H