Question
Write the definitions of the functions class personType and class candidateType, of the programming example Election Results. (anywhere it says see programming exercise 13) #include
Write the definitions of the functions class personType and class candidateType, of the programming example Election Results. (anywhere it says "see programming exercise 13)
#include
#include
#include "personType.h"
using namespace std;
void personType::setName(string first, string last)
{
cout << "See Programming Exercise 13" << endl;
}
string personType::getFirstName() const
{
cout << "See Programming Exercise 13" << endl;
return "";
}
string personType::getLastName() const
{
cout << "See Programming Exercise 13" << endl;
return "";
}
//constructor
personType::personType(string first, string last)
{
cout << "See Programming Exercise 13" << endl;
}
const personType& personType::operator=(const personType& right)
{
cout << "See Programming Exercise 13" << endl;
return *this;
}
//overload the operator ==
bool personType::operator==(const personType& right) const
{
return (firstName == right.firstName
&& lastName == right.lastName); }
bool personType::operator!=(const personType& right) const
{
cout << "See Programming Exercise 13" << endl;
return false;
}
bool personType::operator<=(const personType& right) const
{
cout << "See Programming Exercise 13" << endl;
return false;
}
bool personType::operator<(const personType& right) const
{
cout << "See Programming Exercise 13" << endl;
return false;
}
bool personType::operator>=(const personType& right) const
{
cout << "See Programming Exercise 13" << endl;
return false;
}
bool personType::operator>(const personType& right) const
{
cout << "See Programming Exercise 13" << endl;
return false;
}
istream& operator>>(istream& is, personType& pName)
{
is>>pName.firstName>>pName.lastName;
return is;
}
ostream& operator<<(ostream& os, const personType& pName)
{
cout << "See Programming Exercise 13" << endl;
return os;
}
#include
#include
#include
#include "candidateType.h"
using namespace std;
void candidateType::setVotes(int region, int votes)
{
votesByRegion[region - 1] = votes;
}
void candidateType::updateVotesByRegion(int region, int votes)
{
votesByRegion[region - 1] = votesByRegion[region - 1] + votes;
}
void candidateType::calculateTotalVotes()
{
totalVotes = 0;
for (int i = 0; i < NO_OF_REGIONS; i++)
totalVotes += votesByRegion[i];
}
int candidateType::getTotalVotes() const
{
return totalVotes;
}
void candidateType::printData() const
{
cout << left
<< setw(10) << firstName << " "
<< setw(10) << lastName << " ";
cout << right;
for (int i = 0; i < NO_OF_REGIONS; i++)
cout << setw(7) << votesByRegion[i] << " ";
cout << setw(7) << totalVotes << endl;
}
candidateType::candidateType()
{
for (int i = 0; i < NO_OF_REGIONS; i++)
votesByRegion[i] = 0;
totalVotes = 0;
}
bool candidateType::operator==(const candidateType& right) const
{
return(firstName == right.firstName
&& lastName == right.lastName);
}
bool candidateType::operator!=(const candidateType& right) const
{
cout << "See Programming Exercise 13." << endl;
return false;
}
bool candidateType::operator<=(const candidateType& right) const
{
cout << "See Programming Exercise 13." << endl;
return false;
}
bool candidateType::operator<(const candidateType& right) const
{
cout << "See Programming Exercise 13." << endl;
return false;
}
bool candidateType::operator>=(const candidateType& right) const
{
cout << "See Programming Exercise 13." << endl;
return false;
}
bool candidateType::operator>(const candidateType& right) const
{
cout << "See Programming Exercise 13." << endl;
return false;
}
const candidateType& candidateType::operator=(const candidateType& right)
{
cout << "See Programming Exercise 13." << endl;
return *this;
}
const candidateType& candidateType::operator=(const personType& right)
{
cout << "See Programming Exercise 13." << endl;
return *this;
}
ELECTION RESULTS:
#include
#include
#include
#include "candidateType.h"
#include "orderedArrayListType.h"
using namespace std;
const int NO_OF_CANDIDATES = 6;
void fillNames(ifstream& inFile,
orderedArrayListType
void processVotes(ifstream& inFile,
orderedArrayListType
void addVotes(orderedArrayListType
void printHeading();
void printResults(orderedArrayListType
int main()
{
orderedArrayListType
ifstream inFile;
inFile.open("candData.txt");
fillNames(inFile, candidateList);
candidateList.selectionSort();
inFile.close();
inFile.open("voteData.txt");
processVotes(inFile, candidateList);
addVotes(candidateList);
printHeading();
printResults(candidateList);
return 0;
}
void fillNames(ifstream& inFile,
orderedArrayListType
candidateType temp;
for (int i = 0; i < NO_OF_CANDIDATES; i++)
{
inFile >> firstN >> lastN;
temp.setName(firstN, lastN);
cList.insertAt(i, temp);
}
}
void processVotes(ifstream& inFile,
orderedArrayListType
{
cout << "See Programming Exercise 13" << endl;
}
void addVotes(orderedArrayListType
{
candidateType temp;
for (int i = 0; i < NO_OF_CANDIDATES; i++)
{
cList.retrieveAt(i, temp);
temp.calculateTotalVotes();
cList.replaceAt(i, temp);
}
}
void printHeading()
{
cout << " --------------------Election Results---------"
<< "-----------" << endl << endl;
cout << " Votes" << endl;
cout << " Candidate Name Region1 Region2 Region3 "
<<"Region4 Total" << endl;
cout << "--------------------- ------- ------- "
<< "------- ------- ------" << endl;
}
void printResults(orderedArrayListType
{
cout << "See Programming Exercise 13" << endl;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started