-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassic.cpp
More file actions
executable file
·122 lines (107 loc) · 1.93 KB
/
classic.cpp
File metadata and controls
executable file
·122 lines (107 loc) · 1.93 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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//#include "stdafx.h"
#include "classic.h"
Classic::Classic()
{
genre = 'C';
}
Classic::~Classic()
{
}
void Classic::setYear(string year)
{
this->year = year;
setActorandDate();
}
void Classic::setDateandActor(string info)
{
stringstream file(info);
string firstName;
string lastName;
file >> month;
file >> actualYear;
file >> firstName;
file >> lastName;
majorActor = firstName + " " + lastName;
releaseDate = month + " " + year;
}
string Classic::getYear() const
{
return this->year;
}
string Classic::getActualYear() const
{
return actualYear;
}
string Classic::getMonth() const
{
return this->month;
}
void Classic::setActorandDate()
{
string line = getYear();
stringstream stream(line);
string firstName;
string lastName;
stream >> firstName;
stream >> lastName;
stream >> month;
stream >> actualYear;
majorActor = firstName + " " + lastName;
releaseDate = month + " " + year;
}
bool Classic::operator==(const Movie & rhs) const
{
const Classic* c = dynamic_cast<const Classic *>(&rhs);
return actualYear == c->actualYear && month == c->month && majorActor == c->majorActor;
}
bool Classic::operator!=(const Movie & rhs) const
{
if (*this == rhs)
{
return false;
}
return true;
}
bool Classic::operator>(const Movie & rhs) const
{
const Classic* c = dynamic_cast<const Classic *>(&rhs);
if (actualYear > c->actualYear)
{
return true;
}
else if(actualYear < c->actualYear)
{
return false;
}
if (month > c->month)
{
return true;
}
else if (month < c->month)
{
return false;
}
if (majorActor > c->majorActor)
{
return true;
}
else
{
return false;
}
}
bool Classic::operator<(const Movie & rhs) const
{
if (*this == rhs)
{
return false;
}
else if (*this > rhs)
{
return false;
}
else
{
return true;
}
}