-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCounty.h
75 lines (75 loc) · 2.51 KB
/
County.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
#pragma once
#include "Party.h"
#include "Citizen.h"
#include "CountyDelegate.h"
#include "DynamicArray.h"
#include <vector>
#include <string>
#include <iostream>
#include <list>
using namespace std;
namespace votes
{
static const int SIMPLE = 1;
static const int COMPLEX = 0;
struct Elector
{
int sumElectors;
Party* party;
};
struct voteData
{
int sumDelegates;
Party* party;
int numVotes;
float precentage;
};
class County
{
protected:
DynamicArray <CountyDelegate*> CDArr;
int _countySerial;
string _countyName;
int _numdelegates;
list <Citizen*> _citizenAllowed;
static int countyCounter;
public:
//ctors/dtors:
County(const string& countyName, int numdelegates);
County();
virtual ~County();
// we don't use a "County" by-val initing, but we make sure no code will be using default operator '=' or 'copy ctor' by cancelling them.
County(const County& other) = delete;
County& operator=(const County& other) = delete;
//
void AddCitizen(const string& name, int id, int year);
void AddCD(Citizen* delegate,Party* party);
friend ostream& operator<<(ostream& os, const County& county);
Citizen* searchCitizen(int id)const;
Citizen* findCitizen(int id) const;
void resetCounter() { countyCounter = 0; }
//getters:
void getVotes(vector<int>& voteArr) const;
const int getSize() const { return static_cast<int>(_citizenAllowed.size()); }
CountyDelegate* getDelgate(int delgatePlace)const;
const string getCountyName() const { return _countyName; }
int getCountySerial() const { return _countySerial; }
const int getdelegatesNum() const { return this->_numdelegates; }
const int getDelgatesarrSize()const { return static_cast<const int>(CDArr.size()); }
const int getCountySize()const { return static_cast<const int>(_citizenAllowed.size()); };
Citizen* getCitizenByIndex(int index)const;
void getCountyVotes(vector<int>& votearr);
virtual void GetPartiesElectors(vector<float>& statisticsArray, vector<int>& countyElectors, int partiesSize)const = 0;
CountyDelegate* getDel(int place)const { return CDArr.at(place); }
//printers:
void PrintList(const string& countyName) const;
virtual void sortAndPrintWinners(vector<int>& voteCount, vector<int>& Electors, int partiesSize, list <Party*> partylist)const = 0;
void PrintCitizenList() const;
virtual void printCountyType() const = 0;
//savers/loaders
void saveCitizensList(ostream& out) const;
void loadCitizensList(istream& in);
virtual void saveCounty(ostream& out) const=0;
void loadCounty(istream& in);
};
}