Advertisement
teknique

Untitled

Nov 19th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.64 KB | None | 0 0
  1. class countyElectionResults{
  2.  
  3.   friend ostream &operator<<(ostream &, countyElectionResults);
  4.  
  5.  
  6. public:
  7.  
  8.   // Constructor - just initializes internal variables
  9.   countyElectionResults();
  10.  
  11.   // Constructor - initializes internal variables and loads data from file
  12.   // string parameter is filename
  13.   countyElectionResults(string filename);
  14.  
  15.   // Loads data from a file, string parameter is the filename
  16.   // returns true if it worked, and false if not
  17.   bool loadFile(string filename);
  18.  
  19.   // Returns the county name
  20.   string getCountyName();
  21.  
  22.   // Returns the vector that contains all the votes that were loaded
  23.   vector<char> getVotes();
  24.  
  25.   // Prints the votes that were loaded
  26.   void showVotes();
  27.  
  28.   // Returns the total nullifier votes
  29.   int getNullifierVotes();
  30.  
  31.   // Returns the total fieldite votes
  32.   int getFielditeVotes();
  33.  
  34.   // Returns the total third party votes
  35.   int getOtherVotes();
  36.  
  37.   // Returns the total number of votes
  38.   int getTotalVotes();
  39.  
  40. private:
  41.   string countyName;
  42.   vector<char> votes;
  43.   int nullifierVotes;
  44.   int fielditeVotes;
  45.   int otherVotes;
  46.  
  47.   // A private function that counts all the votes stored in the
  48.   // votes vector
  49.   void countVotes();
  50.  
  51. };
  52.  
  53. class stateElectionResults {
  54.  
  55. public:
  56.   // Asks the user for a file name, then loads that file into
  57.   // a countyElectionObject from that file and places it into a vector
  58.   void addCountyFile();
  59.  
  60.   // Prints the results from all countyElection results
  61.   void showAllCountyResults();
  62.  
  63.   // Prints the results from one county whose name is passed as a string
  64.   void showCountyResults(string);
  65.  
  66.   // Prints votes from one county whose name is passed as a string
  67.   void showCountyVotes(string);
  68.  
  69.   // Prints the names of the counties that are stored in the vector.
  70.   void listCounties();
  71.    
  72.  
  73. private:
  74.   vector<countyElectionResults> stateResults;;
  75.  
  76. };
  77.  
  78.  
  79.  
  80. int main(){
  81.  
  82.  
  83. //   // This main was just for testing operation of the countyElectionsResult class
  84. //   countyElectionResults countyFile;
  85. //   string filename;
  86.  
  87. //   cout << "Enter file name: ";
  88. //   cin >> filename;
  89.  
  90. //   countyFile.loadFile(filename);
  91.  
  92. //   cout << setw(50) << countyFile.getCountyName() << endl;
  93. //   cout << setw(30) << "Nullifier: " << setw(20) << countyFile.getNullifierVotes() << endl;
  94. //   cout << setw(30) << "Fieldite: " << setw(20) << countyFile.getFielditeVotes() << endl;
  95. //   cout << setw(30) << "Other: " << setw(20) << countyFile.getOtherVotes() << endl;
  96. //   cout << setw(30) << "Total: " << setw(20) << countyFile.getTotalVotes() << endl;
  97. //   cout << endl;
  98. //   countyFile.showVotes();
  99. //   cout << countyFile << endl;
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement