-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
84 lines (61 loc) · 1.88 KB
/
main.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
73
74
75
76
77
78
79
80
81
82
83
84
#include "User.h"
#include "MediaItem.h"
#include "Book.h"
#include "Movie.h"
#include "Library.h"
#include <iostream>
#include <string>
using namespace std;
int main() {
Library library;
MediaItem item;
User user;
string name;
cout << "Welcome to the library. Please enter your first name to quick start: ";
getline(cin, name);
user.setName(name);
int option = 0;
cout << "\nWelcome, " << name << ".";
do {
library.displayMenu();
cout << "Please select an option from the menu: ";
cin >> option;
system("cls");
switch (option) {
case 1:
library.displayAllItems();
break;
case 2:
int addItem;
library.displayAllItems();
cout << "Which item would you like to add? ";
cin >> addItem;
user.addBorrowedItem(&(library.getAllItems().at(addItem-1)));
cout << "Item successfully added." << endl;
break;
case 3:
int removeItem;
user.displayBorrowedItems(user);
if (!user.hasBorrowedItems()) {
cout << "No borrowed items." << endl;
}
else {
user.displayBorrowedItems(user);
cout << "Which item would you like to remove? ";
cin >> removeItem;
user.removeBorrowedItem(removeItem - 1);
cout << "Item successfully removed." << endl;
}
break;
case 4:
if (!user.hasBorrowedItems()) {
cout << "No borrowed items." << endl;
}
else {
user.displayBorrowedItems(user);
}
break;
};
} while (option != 9);
return 0;
}