-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomedy.cpp
91 lines (79 loc) · 3.22 KB
/
comedy.cpp
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
//----------------------------------------------------------------------------
// Comedy.cpp
// Implementation:
// -- This class is responsible for handling the comedy movies available in
// the store. Comedy inherits the public variables and methods from Movie.
// Assumptions:
// -- Data file will be formatted correctly, although data may be incorrect
// -- Factory determines which type of movie object is created
//----------------------------------------------------------------------------
#include "comedy.hpp"
//--------------------------------constructor---------------------------------
// creates empty Comedy movie
Comedy::Comedy() : Movie() { }
//---------------------------------destructor---------------------------------
// needed to delete Drama
Comedy::~Comedy() { }
//----------------------------------setData-----------------------------------
// sets the data for the blank drama object after the factory creates a new
// drama movie
void Comedy::setData(ifstream& infile) {
infile.ignore();
infile >> stock;
infile.ignore();
getline(infile >> ws, director, ',');
infile.ignore();
getline(infile >> ws, title, ',');
infile >> year;
}
//-------------------------------setTempData----------------------------------
// sets temporary data in processTransactions so movie can be retrieved from
// the inventory tree
void Comedy::setTempData(ifstream& infile) {
infile.ignore();
getline(infile >> ws, title, ',');
infile >> year;
}
//--------------------------------operator<-----------------------------------
// determines if this is less than the other
bool Comedy::operator<(const Movie& other) const {
const Comedy& comedyMovie = static_cast<const Comedy&>(other);
if (title < comedyMovie.title) {
return true;
} else if (title == comedyMovie.title && year < comedyMovie.year) {
return true;
} else {
return false;
}
}
//--------------------------------operator<-----------------------------------
// determines if this is greater than the other
bool Comedy::operator>(const Movie& other) const {
const Comedy& comedyMovie = static_cast<const Comedy&>(other);
if (title > comedyMovie.title) {
return true;
} else if (title == comedyMovie.title && year > comedyMovie.year) {
return true;
} else {
return false;
}
}
//-------------------------------operator==-----------------------------------
// determines if this is equal to the other
bool Comedy::operator==(const Movie& other) const {
const Comedy& comedyMovie = static_cast<const Comedy&>(other);
return (title == comedyMovie.title && year == comedyMovie.year);
}
//-------------------------------operator!=-----------------------------------
// determines if this is not equal to the other
bool Comedy::operator!=(const Movie& other) const {
const Comedy& comedyMovie = static_cast<const Comedy&>(other);
return !(*this == comedyMovie);
}
//----------------------------------create------------------------------------
// returns a new Comedy object to the factory to be inserted into binary tree
// data will be set right after object is created in the buildInventory
// funtion in the store class.
Movie* Comedy::create() {
return new Comedy();
}