-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
126 lines (110 loc) · 3.88 KB
/
main.cpp
File metadata and controls
126 lines (110 loc) · 3.88 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
#include "Store.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include "Customer.h"
#include "Classic.h"
#include "Drama.h"
#include "Comedy.h"
int main()
{
string minput = "mtest.txt";
string cinput = "data4customers.txt";
string ainput = "data4commands.txt";
Store myStore;
//Input my test customer file*********************
//************************
ifstream infile;
infile.open(minput);
if (!infile)
{
std::cout << "error opening movie data file" << std::endl;
exit(1);
}
std::string line;
while (getline(infile, line))
{
myStore.addMovie(line);
}
infile.close();
//*******************************************
//*********** input my test customer files
infile.open(cinput);
if (!infile)
{
std::cout << "error opening customer data file" << std::endl;
exit(1);
}
while (getline(infile, line))
{
myStore.addCustomer(line);
}
infile.close();
//************************************8
//***RETRIeve customer test*******************
Customer* teed = myStore.remCustomer(1);
cout << teed->getID();
//*********************************************8
//**********attempt duplicate customer input*********
infile.open(cinput);
if (!infile)
{
std::cout << "error opening customer data file" << std::endl;
exit(1);
}
while (getline(infile, line))
{
myStore.addCustomer(line);
}
infile.close();
cout << "success, next line should be blank" << endl << endl;
myStore.doAction("B 0001 D C 8 1942 Ingrid Bergman");
cout << "should fail customer id check." << endl;
myStore.doAction("B 6969 D C 8 1942 Ingrid Bergman");
cout << "should fail movie genre check" << endl;
myStore.doAction("B 0001 D Z 8 1942 Ingrid Bergman");
cout << "should fail movie format check" << endl;
myStore.doAction("B 0001 C C 8 1942 Ingrid Bergman");
cout << "should fail to find movie" << endl;
myStore.doAction("B 0001 D C 8 1942 Engrid Bergman");
cout << "should fail to find movie" << endl;
myStore.doAction("B 0001 D C 18 1942 Ingrid Bergman");
cout << "should fail to find movie" << endl;
myStore.doAction("B 0001 D C 8 1941 Engrid Bergman");
cout << "\n display history, should say borrow" << endl;
teed->displayHistory();
myStore.doAction("B 0001 D C 8 1942 Ingrid Bergman");
myStore.doAction("B 0001 D C 8 1942 Ingrid Bergman");
cout << "2 more for 3 total? " << endl;
teed->displayHistory();
cout << endl << endl << endl;
cout << "should be none to rent" << endl;
myStore.doAction("B 0001 D C 8 1942 Ingrid Bergman");
cout << "try to return from wrong customer" << endl;
myStore.doAction("R 3333 D C 8 1942 Ingrid Bergman");
cout << "try to return from invalid customer" << endl;
myStore.doAction("R 6969 D C 8 1942 Ingrid Bergman");
cout << "try to return from wrong movie info" << endl;
myStore.doAction("R 0001 x C 8 1942 Ingrid Bergman");
cout << "try to return from wrong movie info" << endl;
myStore.doAction("R 0001 D X 8 1942 Ingrid Bergman");
cout << "try to return from wrong movie info" << endl;
myStore.doAction("R 0001 D C 1 1942 Ingrid Bergman");
cout << "try to return from wrong movie info" << endl;
myStore.doAction("R 0001 D C 8 ");
cout << "attempting to return 3 movies." << endl;
myStore.doAction("R 0001 D C 8 1942 Ingrid Bergman");
myStore.doAction("R 0001 D C 8 1942 Ingrid Bergman");
myStore.doAction("R 0001 D C 8 1942 Ingrid Bergman");
cout << "try to return one too many, cant return." << endl;
myStore.doAction("R 0001 D C 8 1942 Ingrid Bergman");
cout << "valid borrow" << endl;
myStore.doAction("B 0001 D C 8 1942 Ingrid Bergman");
cout << "valid borrow" << endl;
myStore.doAction("B 3333 D C 8 1942 Ingrid Bergman");
cout << "valid borrow" << endl;
myStore.doAction("B 3333 D C 8 1942 Ingrid Bergman");
cout << "none left" << endl;
myStore.doAction("B 0001 D C 8 1942 Ingrid Bergman");
system("pause");
}