-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBaseData.h
81 lines (71 loc) · 2.09 KB
/
BaseData.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#pragma once
#include <bits/stdc++.h>
using namespace std;
enum DataType {
_name,
_date,
_director,
_writers,
_actors,
_labels,
_country,
_language,
_runtime,
_producer,
_earnings,
_rating,
_awards,
_reviews,
_photos,
};
class BaseData {
protected:
DataType type;
public:
BaseData (DataType _type): type(_type) {}
// 设置BaseData内部数据统一接口,每种派生类Data实现其所需的接口
virtual void setString(const string &) {};
virtual void setInt(const int &) {};
virtual void setDouble(const double &) {};
// 获取BaseData内部数据统一接口,每种派生类Data实现其所需的接口
virtual string getString() const {};
virtual int getInt() const {};
virtual double getDouble() const {};
virtual vector<string> getVectorString() const {};
virtual void printData (ofstream &) = 0;
// 获取BaseData性质(名称/票房...),每种派生类Data实现其所需的接口
DataType getType();
};
class StringData : public BaseData {
string data;
public:
StringData (DataType _type): BaseData(_type) {}
virtual void setString(const string &);
virtual string getString() const;
virtual void printData (ofstream &);
};
class IntData : public BaseData {
int data;
public:
IntData (DataType _type): BaseData(_type) {}
virtual void setInt(const int &);
virtual int getInt() const;
virtual void printData (ofstream &);
};
class DoubleData : public BaseData {
double data;
public:
DoubleData (DataType _type): BaseData(_type) {}
virtual void setDouble(const double &);
virtual double getDouble() const;
virtual void printData (ofstream &);
DataType getType();
};
class VectorStringData : public BaseData {
vector<string> data;
public:
VectorStringData (DataType _type): BaseData(_type) {}
virtual void setString(const string &); // 给data新增一个string
virtual vector<string> getVectorString() const;
virtual void printData (ofstream &);
};