-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControl.cc
More file actions
88 lines (81 loc) · 1.96 KB
/
Copy pathControl.cc
File metadata and controls
88 lines (81 loc) · 1.96 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
using namespace std;
#include "Control.h"
Control::Control()
{
server = new Server();
}
//Runs the control flow of the program based on the choice returned by the main menu function
void Control::runProgram()
{
int choice=-1;
while (choice != 0) {
mMenu->mainMenu(&choice);
if (choice == 0) {
break;
}
//Initiates the adding of movies
else if (choice == 1) {
cout<<"Made it here"<<endl;
DynArray* temp = new DynArray();
cout<<"Made it here"<<endl;
mMenu->getMovieData(temp);
cout<<"Made it here"<<endl;
server->update(ADD,temp);
}
//Initiates the deleting of movies
else if (choice == 2) {
string * delName;
mMenu->getMovieName(delName);
DynArray* temp = new DynArray();
server->retrieve(temp);
string n;
Movie* m;
bool found=false;
for(int i=0;i<temp->getSize();i++)
{
m=temp->getNthMov(i);
n=m->getTitle();
if(delName->compare(n))
{
found=true;
break;
}
}
if(found)
{
DynArray* tempTwo= new DynArray();
tempTwo->addMovie(m);
server->update(DELETE,tempTwo);
//delete tempTwo;
}
//delete temp;
}
//Prints out all the movies
else if (choice == 3) {
DynArray* temp = new DynArray();
server->retrieve(temp);
mMenu->printMovieData(temp);
}
//Prints out all the movies by genre
else if (choice == 4) {
DynArray* temp = new DynArray();
server->retrieve(temp);
DynArray* tempTwo = new DynArray();
string genre=mMenu->getInGenre();
Movie *m;
Genre *g;
string s;
for(int i=0;i<temp->getSize();i++)
{
m=temp->getNthMov(i);
g=m->getGenre();
s=g->toString();
if(s.compare(genre))
{
tempTwo->addMovie(m);
}
}
mMenu->printMovieData(tempTwo);
}
}
}