-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmoviefactory.cpp
More file actions
executable file
·63 lines (51 loc) · 1.08 KB
/
moviefactory.cpp
File metadata and controls
executable file
·63 lines (51 loc) · 1.08 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
#include "moviefactory.h"
MovieFactory::MovieFactory()
{
}
MovieFactory::~MovieFactory()
{
}
Movie *MovieFactory::createMovie(const char type, istream& file)
{
file.get();
Movie *newMovie = NULL;
switch (type)
{
case 'F':
newMovie = new Comedy;
break;
case 'C':
newMovie = new Classic;
break;
case 'D':
newMovie = new Drama;
break;
default:
{
cout << "Invalid movie type: " << type << endl;
string clear;
getline(file, clear, '\n');
newMovie = NULL;
return NULL;
}
}
string stockString;
int newStock;
string director;
string title;
string otherInfo;
getline(file, stockString, ',');
stringstream num(stockString);
num >> newStock;
newMovie->setStock(newStock);
file.get();
getline(file, director, ',');
newMovie->setDirector(director);
file.get();
getline(file, title, ',');
newMovie->setTitle(title);
file.get();
getline(file, otherInfo, '\n');
newMovie->setYear(otherInfo);
return newMovie;
}