-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
105 lines (80 loc) · 3.29 KB
/
test.cpp
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
#include "catalog.h"
#include "compositeJourney.h"
#include "journey.h"
#include "journeys.h"
#include "simpleJourney.h"
#include <cstring>
#include <iostream>
using namespace std;
int main() {
char start[100], end[100], transport[100];
cout << "===========Test Journey Start===========" << endl;
// cin >> start >> end;
strcpy(start, "Paris");
strcpy(end, "Tianjin");
Journey journey1;
Journey journey2(start, end);
cout << journey1 << endl << journey2 << endl;
cout << "===========Test Journey End===========" << endl;
cout << endl << endl;
cout << "===========Test SimpleJourney Start===========" << endl;
// cin >> start >> end >> transport;
strcpy(start, "Villeurbanne");
strcpy(end, "Saint-Etienne");
strcpy(transport, "car");
SimpleJourney simpleJourney1;
SimpleJourney simpleJourney2(start, end, transport);
cout << simpleJourney1 << endl << simpleJourney2 << endl;
cout << "===========Test SimpleJourney End===========" << endl;
cout << endl << endl;
cout << "===========Test Journeys Start===========" << endl;
Journeys journeys;
cout << journeys << endl;
journeys.Add(new SimpleJourney("Nanjing", "Beijing", "train"));
cout << journeys << endl;
journeys.Add(new SimpleJourney("Lyon", "Tokyo", "plane"));
cout << journeys << endl;
cout << "===========Test Journeys End===========" << endl;
cout << endl << endl;
cout << "===========Test CompositeJourney Start===========" << endl;
CompositeJourney compositeJourney;
cout << compositeJourney << endl;
compositeJourney.Add(new SimpleJourney("Guangzhou", "Shenzhen", "bus"));
cout << compositeJourney << endl;
compositeJourney.Add(new SimpleJourney("Shenzhen", "Honkong", "boat"));
cout << compositeJourney << endl;
compositeJourney.Add(new SimpleJourney("Macao", "Taiwan", "boat"));
cout << compositeJourney << endl;
cout << "===========Test CompositeJourney End===========" << endl;
cout << endl << endl;
cout << "===========Test Catalog Start===========" << endl;
Catalog catalog;
cout << catalog << endl << endl;
catalog.Add(new Journey("Guangzhou", "Shenzhen"));
cout << catalog << endl << endl;
catalog.Add(new SimpleJourney("Shenzhen", "Honkong", "boat"));
cout << catalog << endl << endl;
CompositeJourney *pcompositeJourney = new CompositeJourney;
pcompositeJourney->Add(new SimpleJourney("Wuhan", "Xiamen", "train"));
pcompositeJourney->Add(new SimpleJourney("Xiamen", "Fuzhou", "metro"));
catalog.Add(pcompositeJourney);
cout << catalog << endl << endl;
catalog.Add(new SimpleJourney("Macao", "Taiwan", "boat"));
cout << catalog << endl << endl;
catalog.Add(new Journey("Shenzhen", "Macao"));
catalog.Add(new Journey("Fuzhou", "Macao"));
catalog.Add(new Journey("Guangzhou", "Macao"));
catalog.Add(new Journey("Honkong", "Wuhan"));
catalog.Add(new Journey("Taiwan", "Wuhan"));
catalog.Add(new Journey("Macao", "Wuhan"));
cout << catalog << endl << endl;
cout << catalog << endl << endl;
catalog.Search("Guangzhou", "Taiwan");
cout << endl << endl;
catalog.Search("Honkong", "Macao");
cout << "endl" << endl;
catalog.Search("Honkong", "Maao");
cout << "===========Test Catalog End===========" << endl;
cout << endl << endl;
return 0;
}