-
Notifications
You must be signed in to change notification settings - Fork 0
/
imdb.h
65 lines (51 loc) · 2.41 KB
/
imdb.h
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
/*
* File: imdb.h
* Course: CS216-00x
* Project: Project 1
* Purpose: Declaration of IMDB class
* This class represents a movie-actor database
* It contains two private data memebers:
* movies_db: represents a mapping from a movie (title) to a set of actors (names) in this movie
* actors_db: represents a mapping from a actor (name) to a set of movies (titles) in which this actor is
*/
#ifndef IMDB_H
#define IMDB_H
#include <iostream>
#include <string>
#include <map>
#include <set>
using namespace std;
class IMDB
{
public:
IMDB(); // default constructor
// insert a pair<actorName, the set of movieTitle of this actor>
void insert_an_actor(string actorName, set<string> movieTitles);
// insert a pair <movieTitle, the set of actor names in this movie>
// this function is optional to this project
void insert_a_movie(string movieTitle, set<string> actorNames);
// use passing in parameter, movieTitle, as the pattern to match
// one existing movie in the map
// return the matched movie title from the map
// otherwise return empty string
string matchExistingMovie(string movieTitle) const;
// check if a movieTitle does exist in the map
// return true if it does; otherwise return false
bool isExistingMovie(string movieTitle) const;
// check if an actorName does exist in the map
// return true if it does; otherwise return false
bool isExistingActor(string actorName) const;
// return a set of movie titles which actorName is in
// if the passing in parameter: actorName, is not in the database,
// display message and return an empty set
set<string> find_movies_for_an_actor(string actorName) const;
// return a set of actor names which are all in the movieTitle
// if the passing in parameter: movieTitle is not in the database,
// display message and return an empty set
set<string> find_actors_in_a_movie(string movieTitle) const;
// you are allowed to add more member functions if you need
private:
map<string, set<string> > movies_db; // map of <movie title, set of actors in this movie>
map<string, set<string> > actors_db; // map of <actor name, set of movies this actor is in>
};
#endif /* IMDB_H */