-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.cpp
More file actions
211 lines (187 loc) · 5.35 KB
/
User.cpp
File metadata and controls
211 lines (187 loc) · 5.35 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#include "User.h"
void User::ShowMoviesInfo(Movies& movies)
{
movies.ShowAllMovies();
}
void User::search(Movies& movies)
{
string name;
cout << "What is the name of movie? ";
getline(cin, name);
cin.clear();
cout << "Which kind of search do you want? (1.simple 2.advance)";
size_t typeOfSearch;
cin >> typeOfSearch;
movies.Search(typeOfSearch, name);
}
void User::Filter(Movies& movies)
{
cout << "Filter your movie search based on the following criteria:" << endl;
cout << "1. Genre 2. Score 3. Country 4. Language 5. Release Year" << endl;
cout << "Enter the numbers corresponding to the criteria you'd like to filter by, one at a time." << endl;
cout << "When you are done, enter -1 to proceed." << endl;
vector<int> entries;
while (true)
{
int a;
cin >> a;
if (a == -1)
break;
entries.push_back(a);
}
string genre = "\0";
float score = -1;
string country = "\0";
string language = "\0";
int date = -1;
for (int i = 0; i < entries.size(); i++)
{
if (entries[i] == 1)
{
cout << "Enter the genre you'd like to filter by: ";
cin >> genre;
}
else if (entries[i] == 2)
{
cout << "Enter the minimum score (e.g., 7 for movies rated 7 or higher): ";
cin >> score;
}
else if (entries[i] == 3)
{
cout << "Enter the country you'd like to filter by: ";
cin >> country;
}
else if (entries[i] == 4)
{
cout << "Enter the language you'd like to filter by (e.g., English, French): ";
cin >> language;
}
else if (entries[i] == 5)
{
cout << "Enter the release year you'd like to filter by (e.g., 2021): ";
cin >> date;
}
else
{
cout << "Invalid input. Please enter a valid number from the list (1-5) or -1 to finish." << endl;
}
}
cout << "Applying your filters..." << endl;
movies.Filter(genre, language, date, country, score);
}
void User::ShowFavoritesMovieList(Movies& movies)
{
interestedMovieList.showList(movies);
}
void User::InsertToFavoriteList(Serials& serials, string name)
{
interestedSerialList.insert(serials, name);
}
void User::DeleteFromFavoriteList(Serials& serials, string name)
{
interestedSerialList.deleteMovie(serials, name);
}
void User::PrefferdMovies(Serials& serials)
{
serials.showSuggest();
}
void User::Scoring(Serials& serials, string name, float score)
{
serials.setScore(name, score);
}
void User::watch(Serials& serials, string name) {
serials.watch_movie(name);
}
void User::InsertToFavoriteList(Movies& movies,string name)
{
interestedMovieList.insert(movies, name);
}
void User::DeleteFromFavoriteList(Movies& movies, string name)
{
interestedMovieList.deleteMovie(movies, name);
}
void User::PrefferdMovies(Movies& movies)
{
movies.showSuggest();
}
void User::Scoring(Movies& movies, string name,float score)
{
movies.setScore(name, score);
}
void User::watch(Movies& movies, string name) {
movies.watch_movie(name);
}
void User::ShowMoviesInfo(Serials& serials)
{
serials.ShowAllSerials();
}
void User::search(Serials& serials)
{
string name;
cout << "What is the name of serial? ";
getline(cin, name);
cin.clear();
cout << "Which kind of search do you want? (1.simple 2.advance)";
size_t typeOfSearch;
cin >> typeOfSearch;
serials.Search(typeOfSearch, name);
}
void User::Filter(Serials& serials)
{
cout << "Filter your movie search based on the following criteria:" << endl;
cout << "1. Genre 2. Score 3. Country 4. Language 5. Release Year" << endl;
cout << "Enter the numbers corresponding to the criteria you'd like to filter by, one at a time." << endl;
cout << "When you are done, enter -1 to proceed." << endl;
vector<int> entries;
while (true)
{
int a;
cin >> a;
if (a == -1)
break;
entries.push_back(a);
}
string genre = "\0";
float score = -1;
string country = "\0";
string language = "\0";
int date = -1;
for (int i = 0; i < entries.size(); i++)
{
if (entries[i] == 1)
{
cout << "Enter the genre you'd like to filter by: ";
cin >> genre;
}
else if (entries[i] == 2)
{
cout << "Enter the minimum score (e.g., 7 for movies rated 7 or higher): ";
cin >> score;
}
else if (entries[i] == 3)
{
cout << "Enter the country you'd like to filter by: ";
cin >> country;
}
else if (entries[i] == 4)
{
cout << "Enter the language you'd like to filter by (e.g., English, French): ";
cin >> language;
}
else if (entries[i] == 5)
{
cout << "Enter the release year you'd like to filter by (e.g., 2021): ";
cin >> date;
}
else
{
cout << "Invalid input. Please enter a valid number from the list (1-5) or -1 to finish." << endl;
}
}
cout << "Applying your filters..." << endl;
serials.Filter(genre, language, date, country, score);
}
void User::ShowFavoritesSerialList(Serials& serials)
{
interestedSerialList.showList(serials);
}