Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class countyElectionResults{
- friend ostream &operator<<(ostream &, countyElectionResults);
- public:
- // Constructor - just initializes internal variables
- countyElectionResults();
- // Constructor - initializes internal variables and loads data from file
- // string parameter is filename
- countyElectionResults(string filename);
- // Loads data from a file, string parameter is the filename
- // returns true if it worked, and false if not
- bool loadFile(string filename);
- // Returns the county name
- string getCountyName();
- // Returns the vector that contains all the votes that were loaded
- vector<char> getVotes();
- // Prints the votes that were loaded
- void showVotes();
- // Returns the total nullifier votes
- int getNullifierVotes();
- // Returns the total fieldite votes
- int getFielditeVotes();
- // Returns the total third party votes
- int getOtherVotes();
- // Returns the total number of votes
- int getTotalVotes();
- private:
- string countyName;
- vector<char> votes;
- int nullifierVotes;
- int fielditeVotes;
- int otherVotes;
- // A private function that counts all the votes stored in the
- // votes vector
- void countVotes();
- };
- class stateElectionResults {
- public:
- // Asks the user for a file name, then loads that file into
- // a countyElectionObject from that file and places it into a vector
- void addCountyFile();
- // Prints the results from all countyElection results
- void showAllCountyResults();
- // Prints the results from one county whose name is passed as a string
- void showCountyResults(string);
- // Prints votes from one county whose name is passed as a string
- void showCountyVotes(string);
- // Prints the names of the counties that are stored in the vector.
- void listCounties();
- private:
- vector<countyElectionResults> stateResults;;
- };
- int main(){
- // // This main was just for testing operation of the countyElectionsResult class
- // countyElectionResults countyFile;
- // string filename;
- // cout << "Enter file name: ";
- // cin >> filename;
- // countyFile.loadFile(filename);
- // cout << setw(50) << countyFile.getCountyName() << endl;
- // cout << setw(30) << "Nullifier: " << setw(20) << countyFile.getNullifierVotes() << endl;
- // cout << setw(30) << "Fieldite: " << setw(20) << countyFile.getFielditeVotes() << endl;
- // cout << setw(30) << "Other: " << setw(20) << countyFile.getOtherVotes() << endl;
- // cout << setw(30) << "Total: " << setw(20) << countyFile.getTotalVotes() << endl;
- // cout << endl;
- // countyFile.showVotes();
- // cout << countyFile << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement