-
Notifications
You must be signed in to change notification settings - Fork 1
/
Movie.hpp
86 lines (75 loc) · 1.66 KB
/
Movie.hpp
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
/**
* Name: Rui Deng
* Dadong Jing
* Data: Mar 10, 2016
* Overview: a class contains the information of a movie(name, actors, year)
* Assignment number: PA4
*/
#ifndef MOVIE_HPP
#define MOVIE_HPP
#include "ActorNode.hpp"
#include <vector>
#include <string>
using namespace std;
/**
* movie class to store the movie name, year and all the actors that
* appear in the movie
*/
class Movie
{
public:
//movie name, year and actor list as memeber variables
string name;
int year;
vector<ActorNode*> *actorList;
/**
* constructor to initialize all member variables
* param: a string to initialize the movie name
* an int to initialize the year
*/
Movie(string movName, int ye) : name(movName),year(ye)
{
actorList = new vector<ActorNode*>();
}
/**
* weight of movie used for weighted graph
*/
int weight()
{
return (1 + (2015 - year));
}
/**
* destructor for movie object
*/
~Movie()
{
delete actorList;
}
};
/**
* comparator class used to compare two movies
*/
class movieCmp
{
public:
/**
* override the comparator to compare two Movie pointer
* param: two Movie pointers passed in to be compared
*/
bool operator()(Movie* firstMov, Movie* secondMov)
{
//compare the year of two nodes if years are different
int yearOne = firstMov->year;
int yearTwo = secondMov->year;
if(yearOne != yearTwo)
{
return yearOne > yearTwo;
}
//otherwise compare the names
else
{
return (firstMov->name.compare(secondMov->name)) < 0;
}
}
};
#endif //MOVIE_HPP