-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInventoryModule.cpp
72 lines (63 loc) · 1.71 KB
/
InventoryModule.cpp
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
#include "InventoryModule.h"
InventoryModule::InventoryModule(Inventory* db) : MenuModule(db)
{
}
InventoryModule::~InventoryModule()
{
}
void InventoryModule::PrintMenu()
{
cout << "\n1. Search By Partial ISBN";
cout << "\n2. Search By Partial Title";
cout << "\n3. Add Book";
cout << "\n4. Edit Book";
cout << "\n5. Delete Book";
cout << "\n6. Exit to previous menu\n";
}
void InventoryModule::ProcessUserInput()
{
string userInput;
getline(cin, userInput);
if (userInput.length() > 1)
throw "Invalid input";
InventoryBook *temp;
switch (userInput[0])
{
case '1':
cout << "Enter search string: ";
getline(cin, userInput);
if (temp = database->searchBookByPartialIsbn(userInput.c_str()))
cout << *temp;
break;
case '2':
cout << "Enter search string: ";
getline(cin, userInput);
if (temp = database->searchBookByPartialTitle(userInput.c_str()))
cout << *temp;
break;
case '3':
temp = new InventoryBook();
temp->getData();
database->addBook(*temp);
delete temp;
break;
case '4':
cout << "Searching by title. Enter search string: ";
getline(cin, userInput);
if (temp = database->searchBookByPartialTitle(userInput.c_str()))
database->editBook(temp);
break;
case '5':
cout << "Searching by title. Enter search string: ";
getline(cin, userInput);
if (temp = database->searchBookByPartialTitle(userInput.c_str()))
database->deleteBook(temp);
break;
case '6':
is_terminated = true;
break;
default:
throw "Invalid input";
break;
}
}