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