-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrama.cpp
More file actions
62 lines (53 loc) · 1.05 KB
/
drama.cpp
File metadata and controls
62 lines (53 loc) · 1.05 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
/*
* drama.cpp
*
* @author Juan Arias & Nick Tibbott
*
*/
#include <sstream>
#include "drama.h"
/*
* Constructor from a title, director and release year
*/
Drama::Drama(const string& title, const string& director, int releaseYear)
:Movie(title, director, releaseYear) {
}
/*
* Display the Items details
*/
void Drama::display(ostream& os) const {
Movie::display(os);
os << this->releaseYear;
}
/*
* Returns the most specific type identifier of the item
*/
char Drama::getType() const {
return 'D';
}
/*
* Return the item key
*/
string Drama::getKey() const {
stringstream ss;
ss << "D " << director << ", " << title;
return ss.str();
}
/*
* Constructor to self register in MovieType class
*/
DramaFactory::DramaFactory() {
MovieType::registerType('D', this);
}
/*
* Creates and returns the right Movie from the vector of string
*/
Movie* DramaFactory::create(const vector<string>& tokens) const {
return new Drama(tokens[2], tokens[1], std::stoi(tokens[3]));
}
/*
* Anonymous global for self registering
*/
namespace {
DramaFactory dramaFactory;
}