-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubway.h
65 lines (53 loc) · 1.3 KB
/
subway.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
#ifndef SUBWAY_H
#define SUBWAY_H
#include <QColor>
#include <QPair>
#include <QPointF>
#include <QSet>
#include <QString>
#include <QVector>
#include <cmath>
class Graph;
class QTextStream;
// 边
typedef QPair<int, int> Edge;
// 站点
class Station
{
private:
int id; // 站点ID
QString name; // 站点名称
double longitude, latitude; // 经纬度
QSet<int> belongLines; // 站点所属线路
// 站点的边界位置
static double minLongitude, minLatitude, maxLongitude, maxLatitude;
// 站点间距离
double distance(Station other);
public:
// 构造函数
Station() = default;
Station(QString name, double longitude, double latitude, QList<int> linesList);
// 声明友元
friend class Graph;
friend class QTextStream;
};
// 线路
class Line
{
private:
int id; // 线路ID
QString name; // 线路名称
QColor color; // 线路颜色
QSet<int> stationsSet; // 线路包含站点
QSet<Edge> edges; // 线路站点连接关系
public:
//构造函数
Line() = default;
Line(QString name, QColor color)
: name(name)
, color(color){};
//声明友元
friend class Graph;
friend class QTextStream;
};
#endif // SUBWAY_H