-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrama.cpp
More file actions
51 lines (45 loc) · 1.4 KB
/
drama.cpp
File metadata and controls
51 lines (45 loc) · 1.4 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
/**
* Comedy.h
* Drama class of Movies, a Drama is a specific type of Movie
* Dramas (‘D’) are sorted by Director, then Title
*
* @author Olga Kuriatnyk
*/
#include "drama.h"
// explicit constructor
Drama::Drama(const char &movieType) { this->movieType = movieType; }
// Default destructor
Drama::~Drama() = default;
// reads the line from the file and sets the values to this object
// has validation check for stock and year
bool Drama::read(istream &is) {
char discardComma;
is >> this->stock;
is >> discardComma;
this->director = readNextItem(is);
this->title = readNextItem(is);
is >> this->year;
if (!isStockValid()) {
cerr << "ERROR: invalid stock" << endl;
return false;
}
if (!isYearValid()) {
cerr << "ERROR: invalid year" << endl;
return false;
}
this->director += ",";
this->title += ",";
this->mediaType = 'D'; // because right now we only have one media type
this->itemKey = ItemKey(this->director, this->title); // set ItemKey
return true;
}
// print our drama movie object
void Drama::printMovie() const {
cout << "GENRE: " << this->getMovieType() << ", TITLE: " << this->title;
cout << "\n\tDirector: " << this->director
<< " Year released: " << this->year;
cout << ", In-stock: " << this->stock << ", Borrowed: " << this->borrowedNum
<< endl;
}
// creating the object registers the type at run time
DramaFactory anonymousDramaFactory;