-
Notifications
You must be signed in to change notification settings - Fork 2
/
Map.h
90 lines (73 loc) · 2.25 KB
/
Map.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
82
83
84
85
86
87
88
89
90
//
// Created by Safwan Ahmed on 2021-09-22.
//
#include <string>
#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#ifndef PREP_MAPLOADER_H
#define PREP_MAPLOADER_H
#endif //PREP_MAPLOADER_H
using namespace std;
class Territory{
public:
string name;
int number;
int maxNumberOfArmies;
int continentNumber;
int numberOfArmies;
int Bonus;
int get_numberOfArmies();
void SetNumberOfArmies(int numberOfArmies);
std::vector<Territory*> edges;
Territory(string,int,int,int);
Territory(const Territory &b);
Territory();
void verifyTerritory();
map<int,Territory*> makeTerritoryCopies(unordered_map<int,vector<int>> &neighbours);
Territory& operator =(const Territory &t);
};
void reursiveCopy( unordered_map<int,bool>&,Territory *t, map<int,Territory*> &,unordered_map<int,vector<int>>&);
void mapCopy(vector<Territory*>&,unordered_map<int,bool>&,Territory *t);
ostream& operator <<(ostream &strm,const Territory&t) ;
class Map{
public:
vector<Territory*> map;
vector<Territory*> continents;
//Added for testing
Map( vector<Territory*> map , vector<Territory*> continents);
Map( const Map &m);
Map();
Map& operator =(const Map &m);
bool validate() const;
bool checkContinents() const;
void printMap();
void printContinents();
~Map();
void continentBonus();
};
ostream& operator <<(ostream &strm,const Map&t) ;
class MapLoader{
public:
bool loadMaps(fstream &strm);
explicit MapLoader(Map*);
MapLoader(const MapLoader &m);
MapLoader& operator =(const MapLoader &m);
private:
public:
Map *map;
bool addCountries(fstream &strm);
bool addContinents(fstream &strm);
bool addAdjacentTerritories(fstream &strm);
};
vector<string> tokenize(string);
int mapNumToArrayIndex(int i);
void dfs(vector<bool>&,Territory*);
void dfsSubGraph(vector<bool>&,Territory*,int);
bool checkConnectedGraph(vector<Territory*>);
void clearBoolArray(vector<bool>&,int);
bool checkBoolArray(vector<bool>&);
vector<int> getTerritoryNumbers(Territory *t);
bool checkBoolArraySubGraph(vector<bool>&,vector<int>);
bool checkSubGraphConnected(vector<Territory*>,int);