[solved]-Hello Bit Trouble Verified Exit Program Reason Trying Exit Loops Team Selection Function C Q39046040
Hello i am having a bit of trouble with a verified exit for myprogram. For some reason when trying to exit it loops to the teamselection function?
C++ Visual Studio 2017
#include “cPlayer.h”
char chChoice1 = ‘ ‘;
char chChoice3 = ‘ ‘;
cPlayer::cPlayer()
{
}
cPlayer::~cPlayer()
{
}
void cPlayer::fMenu()
{
char chChoice3 = ‘ ‘;
do
{
cout << “nt–Menu–“<< endl;
cout << “1) Enter PlayerName” << endl;
cout << “2) Select Player’sTeam” << endl;
cout << “3) Display PlayerInfo” << endl;
cout << “4) Exit” <<endl;
cin >> chChoice1;
system(“cls”);
switch (chChoice1)
{
case ‘1’:
fPlayerName();
system(“pause”);
system(“cls”);
fMenu();
break;
case ‘2’:
fSelectTeam();
system(“pause”);
system(“cls”);
fMenu();
break;
case ‘3’:
fPlayerInfo();
system(“pause”);
system(“cls”);
fMenu();
break;
case ‘4’:
fVerifyExit();
break;
default:
cout <<“**********************” << endl;
cout <<“–Not a valid option–” << endl;
cout <<“**********************” << endl;
system(“pause”);
break;
}
} while (chChoice1 != ‘e’);
}
void cPlayer::fSelectTeam()
{
//chChoice2 is a character variable
char chChoice2 = ‘ ‘;
while (true)
{
cout << “Please select yourteam color.” << endl;
cout << “1) Red” <<endl;
cout << “2) Blue” <<endl;
cin >> chChoice2;
switch (chChoice2)
{
case ‘1’:
system(“cls”);
sPlayer.strTeamName = “Red”;
fMenu();
break;
case ‘2’:
system(“cls”);
sPlayer.strTeamName = “Blue”;
fMenu();
break;
default:
cout <<“Invalid Input.” << endl;
return;
}
}
}
void cPlayer::fPlayerInfo()
{
cout << “t–PLAYER INFO–” << endl;
cout << “Player Name: ” <<sPlayer.strPlayerName << endl;
cout << “Team: ” << sPlayer.strTeamName<< endl;
}
void cPlayer::fPlayerName()
{
cout << “Enter the players name.” <<endl;
cin >> sPlayer.strPlayerName;//MAKE A GETLINE
}
char cPlayer::fVerifyExit()
{
char chChoice = ‘ ‘;
system(“cls”);
cout << “Do you want to exit (Y/y).” <<endl;
cin >> chChoice;
switch (chChoice)
{
case ‘Y’:
case ‘y’:
chChoice1 = ‘e’;
break;
default:
chChoice1 = ‘ ‘;
break;
}
return chChoice1;
}
Expert Answer
Answer to Hello i am having a bit of trouble with a verified exit for my program. For some reason when trying to exit it loops to … . . .
OR

