-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapDriver.cpp
More file actions
73 lines (52 loc) · 2.04 KB
/
MapDriver.cpp
File metadata and controls
73 lines (52 loc) · 2.04 KB
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
#include "Map.h"
#include <iostream>
using std:: end;
using std:: cout;
int main () {
cout<<"**** MAP SECTION ****"<<endl;
MapLoader* loader = new MapLoader();
// Example of a map file that doesn't exist
Map* map1 = loader->loadMap("house.map");
// Examples of both valid/invalid map files
Map* map2 = loader->loadMap("Chrono_Trigger.map");
map2->validate();
Map* map3 = loader->loadMap("periodict.map");
map3->validate();
/* Solar map was modified by adding a new continent containing one territory
which has no adjacent territories to showcase a case where the map is not connected as a whole.
Explanation: having no adjacent territories means that it cannot be reached from the starting territor/node
therefore, map is not connected
*/
Map* map4 = loader->loadMap("solar.map");
map4->validate();
Map* map5 = loader->loadMap("europe.map");
map5->validate();
// Prints continents of map 5 - europe.map
// I'm trying to print out the continent object but I get its address instead of its name
cout<< "\nContinents in map [europe.map]:"<<endl;
for(auto it: map5->getContinents()){
cout<<*it<<endl;
}
// Prints territories of a continent in map 5 - europe.map
for(auto continent: map5->getContinents()){
cout<<"\nContinent "<<*continent<<" has territories: "<<endl;
for(auto territory: continent->getTerritories()){
cout<<*territory<<endl;
}
}
// Prints adjacent territories of some territories in map 5 - europe.map
for (int i = 0; i <= 3 ; i++){
cout<<"\nTerritory "<<*map5->getTerritories()[i]<<" has these adjacent territories: "<<endl;
for(int j = 0; j < map5->getTerritories()[i]->getAdjacentTerritories().size(); j++){
cout<<*map5->getTerritories()[i]->getAdjacentTerritories()[j]<<endl;
}
}
// Calling the map destructor becuase the maps have been dynamically allocated
cout<<"\nDeleting maps: "<<endl;
vector <Map*> maps {map1, map2, map3, map4, map5};
for (auto mapObject : maps){
delete(mapObject);
}
cout<< "Maps deleted. "<<endl;
cout<<"\n**** MAP END ****"<<endl;
}