Hello again,
I have a question related to one of the classes I am building. I asked a similar question in this forum before and I have not gotten any substantial answers so I thought I would try one more time... Presenting my class...
The function I am having particular trouble with is the void Display function... I need to do what this blurb tells me to do...Code:#ifndef BALLOT_H
#define BALLOT_H
enum Chad {PUNCHED, HANGING, DIMPLED, NONE};
enum Choice {BUSH, GORE, BUCHANAN, OTHER, MULTIPLE};
class Ballot
{
public:
Ballot();
void RecordVote(Choice c, Chad ch, int a);
Choice GetCandidate();// returns the candidate that is marked
Chad GetMark();// returns the marking on the chad
int GetAge();// returns the age
void Display();// displays ballot info (format given below)
private:
Choice who;// candidate that is (or seems to be) marked
Chad mark;// marking on the selected chad
int age;// age of voter
};
#endif
So far my attempts have been less than successful.. This is my definition of the void Display() function:Code:
void Display(); // displays ballot info (format given below)
// For the Display function, output the ballot choice, the Chad marking,
// and the age of the voter, all on one line. IF the chad marking is
// NONE, then this is a "no vote", so display "No Vote" in the
// ballot choice position (regardless of the actual contents of
// the candidate variable).
// Examples: Bush Punched Age: 37
// Gore Hanging Age: 82
// No Vote None Age: 53
Please let me know why my output does not get as neat as the one in the examples. Thank you.Code:void Ballot::Display()
// In essence, this would be the display for one ballot
// the format should be like the following:
// 1) Bush Punched Age: 23
{
// since this is the display for one ballot card
// we put the number list in the Tally::Display()
if (mark == NONE){
switch(who)
{
case BUSH: cout << setw(7) << "No Vote"; break;
case GORE: cout << setw(7) << "No Vote"; break;
case BUCHANAN: cout << setw(7) << "No Vote"; break;
case OTHER: cout << setw(7) << "No Vote"; break;
case MULTIPLE: cout << setw(7) << "No Vote"; break;
}
cout << "None";
}
else {
switch(who)
{
case BUSH: cout << setw(7) << "Bush"; break;
case GORE: cout << setw(7) << "Gore"; break;
case BUCHANAN: cout << setw(7) << "Buchanan"; break;
case OTHER: cout << setw(7) << "Other"; break;
case MULTIPLE: cout << setw(7) << "Multiple"; break;
}
switch(mark)
{
case PUNCHED: cout << "Punched"; break;
case HANGING: cout << "Hanging"; break;
case DIMPLED: cout << "Dimpled"; break;
}
}
cout << setw(7) << "Age: " << age;
}