-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
140 lines (119 loc) · 3.59 KB
/
main.cpp
File metadata and controls
140 lines (119 loc) · 3.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
138
139
140
/**
* @file main.cpp
* @authors Anna Hensley, Dylan Daniels
* @date 2024-11-08
* @brief is the main file for the library program
*
* includes the UI code for the library
*/
#include "library.h"
#include <iostream>
using namespace std;
int main() {
Library PML;
int choice;
string fileName, authorsFN, authorsLN, bookTitle, isbn;
int pages, year;
float price;
do {
cout << endl;
cout << "Hello! Please select one of the following options." << endl;
cout << endl;
cout << "1. Read from a specific library file.\n"
<< "2. Write the library to a file.\n"
<< "3. See a complete list of all the books in the library.\n"
<< "4. Search for a specific book.\n"
<< "5. Look to see if we have any books by a specific author!\n"
<< "6. If donating a book, please submit the book's information.\n"
<< "7. If a book is missing, please submit the book's information.\n"
<< "8. Exit this program.\n";
cin >> choice;
cout << endl;
switch (choice) {
case 1: {
cout << "Please enter the library file to read from: ";
cin >> fileName;
PML.read_from_file(fileName);
break;
}
case 2: {
cout << "Please enter the name of the file to write to: ";
cin >> fileName;
PML.write_to_file(fileName);
break;
}
case 3: {
PML.print();
break;
}
case 4: {
cout << "In order to find information on a book, please enter the title.\n";
cin.ignore();
getline(cin, bookTitle);
if (!bookTitle.empty()) {
PML.find_album(bookTitle);
} else {
cout << "Oh no! We must not have any books with that title." << endl;
}
break;
}
case 5: {
string authorsName;
cout << "In order to find books by that author, please enter the author's "
<< "full name: ";
cin.ignore();
getline(cin, authorsName);
PML.find_author(authorsName);
break;
}
case 6: {
cout << "Thank you for the donation! Please enter the book's title: ";
cin.ignore();
getline(cin, bookTitle);
string authorsName;
cout <<" Great! Now enter the author's full name: ";
getline(cin, authorsName);
cout << "Please enter the total pages: ";
cin >> pages;
cout << "Enter the ISBN: ";
cin >> isbn;
cout << "Enter the price (format example: 10.99): ";
cin >> price;
cout << "Finally, please enter the Year published: ";
cin >> year;
PML.insert_sorted(bookTitle, authorsName, pages, isbn, price, year);
break;
}
case 7: {
cout << "Thank you for letting us know! Please help us out by entering some "
<< "information." << endl;
cout << "Please enter the book's title: ";
cin.ignore();
getline(cin, bookTitle);
string authorsName;
cout <<" Great! Now enter the author's first name: ";
getline(cin, authorsName);
cout << "Enter the total pages: ";
cin >> pages;
cout << "Enter the ISBN: ";
cin >> isbn;
cout << "Please enter the price: ";
cin >> price;
cout << "Enter the Year published: ";
cin >> year;
PML.genericDelete(authorsName, bookTitle);
break;
}
case 8: {
cout << "Thank you for using our library system. You are now "
<< "Exiting the program. Goodbye!" << endl;
break;
}
default: {
cout << "Invalid choice. Please try again." << endl;
break;
}
}
} while (choice != 8);
return 0;
}