dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Game tracker stress

  1. #1
    Join Date
    Dec 2018
    Posts
    4

    Game tracker stress

    Currently working on a project that has me in tears at this point. I have looked for help and I seem to not be finding it. Here is the code that I have so far. The issue im having is that I cant get it to go into the tie breaker after a tied game. Please help?


    Code:
    #include <iostream>
    #include <iomanip>
     
    using namespace std;
     
    char set12(char teamA[21], char teamB[21], int set);  //Set 1&2.
    char tie(char teamA[16], char teamB[16], int set);   //Set tie.
     
    int main()
    {
        char teamA[21], teamB[21];  
        char yn = 'n'; // yes or no.
        int bScore; //teamB score.
        int aScore; //teamA score.
        int matchA, matchB; //Matches for each team. 
        bool tie = true;
        do
        {
            matchA = matchB = 0;  //Starting 0-0.
             
            cout << "\t\t  Lima Peru Pan American Games Beach Volley Ball  Game Tracker" << endl << endl;
            //Naming teams.
            cout << "Enter the name of Team A: ";  
            cin.getline (teamA, 20);
            cout << "Enter the name of Team B: ";
            cin.getline (teamB, 20);
            //start the game.
            cout << "Let the Games begin !  Best 2 of 3 sets win" << endl << endl;
            //Set 1 status.
    	int set = 1;
            char set1 = set12(teamA, teamB, set);
            if (set1 == 'A')
            {
                cout <<"\n+++++++++ Set to Team A " << teamA <<" +++++++++ "<< endl;
                cout << "Team A " << teamA << " at set count" << set << " to Team B " << teamB << " at set count" << set << endl << endl;
                aScore++;
             }
             else
             {
                cout <<"\n+++++++++ Set to Team B " << teamB <<" +++++++++ " << endl;
                cout << "Team B " << teamB << " at set count " << set << " to Team A " << teamA << " a set count " << set << endl << endl;
                bScore++;
             }
    
             //Set 2 status.
            set++;
            char set2 = set12(teamA, teamB, set);
            if (set2 == 'A')
            {
                cout <<"\n+++++++++ Set to Team A " << teamA <<" +++++++++ "<< endl;
                cout << "Team A " << teamA << " at set count" << set << " to Team B " << teamB << " at set count" << set << endl << endl;
                aScore++;
             }
             else
             {
                cout <<"\n+++++++++ Set to Team B " << teamB <<" +++++++++ " << endl;
                cout << "Team B " << teamB << " at set count "<< set << " to Team A " << teamA << " a set count "<< set << endl << endl;
                bScore++;
             }
    
             set++;
             if (aScore == bScore)   
                 char tie(char teamA[16], char teamB[16], int set);
    
             if (set1 == 'A')
             {
                 cout <<"\n+++++++++ Set to Team A " << teamA <<" +++++++++ "<< endl;
                 cout << "Team A " << teamA << " at set count" << set <<" to Team B " << teamB << " at set count" << set << endl << endl;
                 aScore++;
             }
             else
             {
                cout <<"\n+++++++++ Set to Team B " << teamB <<" +++++++++ " << endl;
                cout << "Team B " << teamB << " at set count " << set << " to Team A " << teamA << " a set count "<< set << endl << endl;
                bScore++;
             }
    
             set++;
             
             if (!tie)  //One last question.
                cout << "Would you like to play again? (Y/N)? ";
    
             cin >> yn;
        } while (yn != 'n' && yn != 'N');
         
        cin.get();
        if (bool tie = true)
    	cout << "Tie breaker required";
    
        return 0;
    }
    
    char set12(char teamA[21], char teamB[21], int set)
    {
        int aPoints = 0;
        int bPoints = 0;
        int totalPoints = 0;
        int win = 21;
        int aWin = 0;
        int bWin = 0;
        bool winner = false;
        bool side = true;
        bool tie = false;
        char point;
        do {
           //Current status of sets.
           if (side)
           {
               cout << " Current Status Set " << setw(7) << right << set << endl;
               cout << " Team A " << setw(20) << right  << teamA << " | " << " Team B " << setw(20) << right << teamB << endl;
               cout << setw(28) << right << aPoints << " | " << setw(28) << right << bPoints << endl;
           }
           else
           {
               cout << " Current Status Set " << setw(7) << right << set << endl;
               cout << " Team B " << setw(20) << right  <<teamB<<" | " << " Team A " << setw(20) << right << teamA << endl;
               cout << setw(28) << right << bPoints << " | " << setw(28) << right << aPoints << endl;
           }
    
           //Requesting score input.
           do {
                cout << "Which team scored a point (A or B)? ";
                cin >> point;
            }  while (point != 'a' && point != 'A' && point != 'b' && point != 'B');
             
            if (point == 'a' || point == 'A')
            {
                   aPoints++;
                   totalPoints++;
            }
            else
            {
                  bPoints++;
                  totalPoints++;
            }
    
            //switch sides counter for sets 1 and 2.
         	if (totalPoints == 8 || totalPoints == 15 || totalPoints == 22 )
            //if (totalPoints%7==0)
            {
               cout << endl << endl << "Switch Sides!!!" << endl;
               side = !side;
            }
       
            if (aPoints >= 21 && aPoints - bPoints >= 2)
            {
                   winner = true;
                   return 'A';
            }
            else 
              if (bPoints >=21 && bPoints-aPoints >=2)
              {
                   winner = true;
                   return 'B';
              }
    
            if (aPoints == 21)
    	{
                aWin = 1;
            }
    
            if (bPoints == 21)
    	{
    	    bWin = 1;
            }
    
            if (aWin == bWin)
                bool tie = true;
    
        } while (!winner);     
    }
    
    
     //Tie game .
    char tie(char teamA[21], char teamB[21], int set)
    {
        int aPoints = 0;
        int bPoints = 0;
        int totalPoints = 0;
        int tiewinner = 16;
        bool tie = true;
        bool side = true;
        char point;
        if (bool tie = true)
            do {
                 //current status of set.
                 if (side)
                 {
                      cout << " Current Status Set Tie Breaker " << setw(7)<< right << set << endl;
                      cout << " Team A " << setw(20) << right  << teamA <<" | " << " Team B " << setw(20) << right << teamB << endl;
                      cout << setw(28) << right << aPoints << " | " << setw(28) << right << bPoints << endl;
             
                 }
                else
                {
                     cout << " Current Status Set Tie Breaker " << setw(7) << right << set << endl;
                     cout << " Team B " << setw(20) << right  << teamB <<" | " << " Team A " << setw(20) << right << teamA << endl;
                     cout << setw(28) << right << bPoints << " | " << setw(28) << right << aPoints << endl;
                }
    
                do
                {
                    cout << "What team scored a point (A or B)? ";
                    cin >> point;
                } while (point != 'a' && point != 'A' && point != 'b' && point != 'B');
    
                // Requesting score input for tie set.
                if (point == 'a' || point == 'A')
                {
                    aPoints++;
                    totalPoints++;
                }
                else
                {
                    bPoints++;
                    totalPoints++;
                }
    		    
               //Switch sides during tie set after 5.
               if (totalPoints == 6 || totalPoints == 16 )
               {
                   cout << endl << endl << "Switch Sides!!!" << endl;
                  side = !side;
               }
    
               if (aPoints >= 16 && aPoints - bPoints >= 2 )
               {
                    tiewinner = true;
                    return 'A';
               }
               else 
                  if (bPoints >=16 && bPoints - aPoints >= 2)
                  {
                     tiewinner = true;
                     return 'B';
                  }
    
                  //Tie winner.
               if (tiewinner = true)
               {
                    char tie(char teamA[21], char teamB[21], int set);
                    if (aPoints == 16)
                    {
                        cout << "Tie breaker and Matches to Team A " << teamA << endl << endl;
                    }
                    else
                    {
                        cout << "Tie breaker and Matches to Team B " << teamB << endl << endl;
                    }
               }
         }while (!tiewinner);
    }
    Last edited by 2kaud; December 11th, 2018 at 05:20 AM. Reason: Added code tags

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,812

    Re: Game tracker stress

    [When posting code, please format your code and use code tags so that the code is readable! Go Advanced, select the formatted code and click '#']

    There are several issues with this code. Before you start looking for logic errors, you'll need to fix these first:

    1)

    Code:
    if (aScore == bScore)   
                 char tie(char teamA[16], char teamB[16], int set);
    This does not call the function tie. It redeclares the function tie! To call the function tie you would use

    Code:
    if (aScore == bScore)   
                 tie(teamA, teamB, set);
    Note that this does not use the value returned by the function.

    2)

    Code:
    if (bool tie = true)
    	cout << "Tie breaker required";
    There are actually 2 issues here. The first is that you are defining a new variable tie that only has scope during the if statement and is a different variable to the tie already defined. The second is that = means assignment so here you are assigning true to tie and then testing for true - which it always will be. == is used for equality test (as used elsewhere). Do you mean

    Code:
    if (tie == true)
    	cout << "Tie breaker required";

    3)
    Code:
    if (aWin == bWin)
                bool tie = true;
    Again, tie is a new variable and is not the same as the previously defined tie. Do you mean

    Code:
    if (aWin == bWin)
                tie = true;
    These issues appear several times in the code so you'll need to alter them throughout the code.

    Have fun!
    Last edited by 2kaud; December 11th, 2018 at 05:21 AM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.2.5)

  3. #3
    Join Date
    Dec 2018
    Posts
    4

    Re: Game tracker stress

    Quote Originally Posted by 2kaud View Post
    [When posting code, please format your code and use code tags so that the code is readable! Go Advanced, select the formatted code and click '#']

    There are several issues with this code. Before you start looking for logic errors, you'll need to fix these first:

    1)

    Code:
    if (aScore == bScore)   
                 char tie(char teamA[16], char teamB[16], int set);
    This does not call the function tie. It redeclares the function tie! To call the function tie you would use

    Code:
    if (aScore == bScore)   
                 tie(teamA, teamB, set);
    Note that this does not use the value returned by the function.

    2)

    Code:
    if (bool tie = true)
    	cout << "Tie breaker required";
    There are actually 2 issues here. The first is that you are defining a new variable tie that only has scope during the if statement and is a different variable to the tie already defined. The second is that = means assignment so here you are assigning true to tie and then testing for true - which it always will be. == is used for equality test (as used elsewhere). Do you mean

    Code:
    if (tie == true)
    	cout << "Tie breaker required";

    3)
    Code:
    if (aWin == bWin)
                bool tie = true;
    Again, tie is a new variable and is not the same as the previously defined tie. Do you mean

    Code:
    if (aWin == bWin)
                tie = true;
    These issues appear several times in the code so you'll need to alter them throughout the code.

    Have fun!
    Thank you for that I agree with the suggestions and understand. I still have the same issue however. I can not get it to go through set1 and set2 and go to tie if the scores are tied. Now this seems to be the biggest issue that I am having.

  4. #4
    Join Date
    Dec 2018
    Posts
    4

    Re: Game tracker stress

    Code:
    #include <iostream>
    #include <iomanip>
     
    using namespace std;
     
    char set12(char teamA[21], char teamB[21], int set);  //Set 1&2.
    char tie(char teamA[16], char teamB[16], int set);   //Set tie.
     
    int main()
    {
        char teamA[21], teamB[21];  
        char yn='n'; // yes or no.
        int bScore; //teamB score.
        int aScore; //teamA score.
        int matchA,matchB; //Matches for each team. 
         
        do
        { matchA=matchB=0;  //Starting 0-0.
            
             
            cout << "\t\t  Lima Peru Pan American Games Beach Volley Ball  Game Tracker" << endl << endl;
             //Naming teams.
            cout << "Enter the name of Team A: ";  
            cin.getline (teamA, 20);
            cout << "Enter the name of Team B: ";
            cin.getline (teamB, 20);
             //start the game.
            cout << "Let the Games begin !  Best 2 of 3 sets win" << endl << endl;
            //Set 1 status.
    		int set = 1;
            char set1 = set12(teamA, teamB, set);
             if (set1=='A')
             {
                cout <<"\n+++++++++ Set to Team A " << teamA <<" +++++++++ "<< endl;
                cout << "Team A " << teamA << " at set count"<<set<<" to Team B " << teamB << " at set count"<<set<< endl<<endl;
                aScore++;
             }
             else
             {
                cout <<"\n+++++++++ Set to Team B " << teamB <<" +++++++++ " << endl;
                cout << "Team B " << teamB << " at set count "<<set<<" to Team A " << teamA << " a set count "<<set<< endl<<endl;
                bScore++;
             }
             //Set 2 status.
            set++;
            char set2 = set12(teamA, teamB, set);
             if (set2 =='A')
             {
                cout <<"\n+++++++++ Set to Team A " << teamA <<" +++++++++ "<< endl;
                cout << "Team A " << teamA << " at set count"<<set<<" to Team B " << teamB << " at set count"<<set<< endl<<endl;
                aScore++;
             }
             else
             {
                cout <<"\n+++++++++ Set to Team B " << teamB <<" +++++++++ " << endl;
                cout << "Team B " << teamB << " at set count "<<set<<" to Team A " << teamA << " a set count "<<set<< endl<<endl;
                bScore++;
             }
    
            
    		set++;
             if(aScore == bScore)   
              tie (teamA, teamB, set);
            if (set2 == 'A')
             {
                cout <<"\n+++++++++ Set to Team A " << teamA <<" +++++++++ "<< endl;
                cout << "Team A " << teamA << " at set count"<<set<<" to Team B " << teamB << " at set count"<<set<< endl<<endl;
                aScore++;
             }
             else
             {
                cout <<"\n+++++++++ Set to Team B " << teamB <<" +++++++++ " << endl;
                cout << "Team B " << teamB << " at set count "<<set<<" to Team A " << teamA << " a set count "<<set<< endl<<endl;
                bScore++;
             }
    
              set++;    
             
             
      if(matchA > matchB || matchB > matchA)  //One last question.
    cout << "Would you like to play again? (Y/N)? ";
        cin >> yn;
        }while(yn !='n' && yn !='N');
          cin.get();
          
          
        if(tie)
    	cout << "Tie breaker required";
    	 cin.get();
        return 0;
    	}
    
    
    char set12(char teamA[21], char teamB[21], int set)
    
    {
        int aPoints = 0;
        int bPoints = 0;
        int totalPoints = 0;
        int win = 21;
        int aWin = 0;
        int bWin = 0;
        bool winner=false;
        bool side=true;
        
        char point;
        do{
         //Current status of sets.
          if(side)
            {
            cout << " Current Status Set " << setw(7)<<right<< set << endl;
            cout << " Team A " << setw(20) << right  <<teamA<<" | " << " Team B " << setw(20) << right << teamB << endl;
            cout << setw(28) << right << aPoints << " | " << setw(28) << right << bPoints << endl;
             
            }
            else
            {
            cout << " Current Status Set " << setw(7)<<right<< set << endl;
            cout << " Team B " << setw(20) << right  <<teamB<<" | " << " Team A " << setw(20) << right << teamA << endl;
            cout << setw(28) << right << bPoints << " | " << setw(28) << right << aPoints << endl;
            }
          //Requesting score input.
            do
            {
                cout << "Which team scored a point (A or B)? ";
                cin >> point;
            }   while(point != 'a' && point != 'A' && point != 'b' && point != 'B');
             
            if(point == 'a' || point == 'A')
                {
                    aPoints++;
                    totalPoints++;
                }
            else
                {
                    bPoints++;
                    totalPoints++;
                }
         //switch sides counter for sets 1 and 2.
         	if (totalPoints==8 || totalPoints==15 || totalPoints==22 )
           
            {
               cout << endl << endl << "Switch Sides!!!" << endl;
               side=!side;
            }
       
        if(aPoints >= 21 && aPoints-bPoints >=2)
                {
                    winner=true;
                    return 'A';
                }
        else if(bPoints >=21 && bPoints-aPoints >=2)
                {
                    winner=true;
                    return 'B';
                }
    if (aPoints ==21)
    	{
    			aWin =1;
        }
        if (bPoints ==21)
    	{
    			bWin =1;
        }
        if (aWin == bWin)
        {
           tie;
          return 'tie';
                }
    
         }while (!winner);     
    }
    
    
     //Tie game .
    char tie(char teamA[21], char teamB[21], int set)
    {
        int aPoints = 0;
        int bPoints = 0;
        int totalPoints = 0;
        int tiewinner = 16;
    
        bool side=true;
        char point;
        
    	
        do{
         //current status of set.
            if (tie)
            {
            cout << " Current Status Set Tie Breaker " << setw(7)<<right<< set << endl;
            cout << " Team A " << setw(20) << right  <<teamA<<" | " << " Team B " << setw(20) << right << teamB << endl;
            cout << setw(28) << right << aPoints << " | " << setw(28) << right << bPoints << endl;
             
            }
            else
            {
            cout << " Current Status Set Tie Breaker " << setw(7)<<right<< set << endl;
            cout << " Team B " << setw(20) << right  <<teamB<<" | " << " Team A " << setw(20) << right << teamA << endl;
            cout << setw(28) << right << bPoints << " | " << setw(28) << right << aPoints << endl;
            }
            do
            {
                cout << "What team scored a point (A or B)? ";
                cin >> point;
            }while(point != 'a' && point != 'A' && point != 'b' && point != 'B');
            // Requesting score input for tie set.
            if(point == 'a' || point == 'A')
                {
                    aPoints++;
                    totalPoints++;
                }
            else
                {
                    bPoints++;
                    totalPoints++;
                }
              
    		    
         //Switch sides during tie set after 5.
             	if (totalPoints==6 || totalPoints==16 )
            {
               cout << endl << endl << "Switch Sides!!!" << endl;
               side=!side;
            }
        if(aPoints >= 16 && aPoints-bPoints >=2)
                {
                    tiewinner=true;
                    return 'A';
                }
        else if(bPoints >=16 && bPoints-aPoints >=2)
                {
                    tiewinner=true;
                    return 'B';
                }
                         //Tie winner.
             if(tiewinner=true)
             {
                char tie(char teamA[21], char teamB[21], int set);
                if (aPoints == 16)
                    {
                        cout << "Tie breaker and Matches to Team A " << teamA << endl << endl;
                        
                    }
                else
                    {
                        cout << "Tie breaker and Matches to Team B " << teamB << endl << endl;
                        
                    }
                 
        }
    }while (!tiewinner);}
    This is what I have now. It runs through set 1 and set 2 but I still ant get it to tie. So frustrating.

  5. #5
    Join Date
    Dec 2018
    Posts
    4

    Re: Game tracker stress

    Been working on it some more. Still can get it to go through the first two sets and on to the tie set and run through or the tiebreaker status only when there is a tie. Any help would be appreciated.

    Code:
    #include <iostream>
    #include <iomanip>
     
    using namespace std;
     
    char set12(char teamA[21], char teamB[21], int set);
    char tie(char teamA[21], char teamB[21], int set);
    float tie();
    int main()
    {
        char teamA[21], teamB[21];
        char yn='n';
        int bScore;
        int aScore;
        int matchA,matchB;
         
        do
        { matchA=matchB=0;
            //cin.ignore();
             
            cout << "\t\t Beach VolleyBall   Game Tracker" << endl << endl;
             
            cout << "Enter the name of Team A: ";
            cin.getline (teamA, 20);
            cout << "Enter the name of Team B: ";
            cin.getline (teamB, 20);
             
            cout << "Let the Games begin !  Best 2 of 3 sets win" << endl << endl;
            //Set 1 status.
    		int set = 1;
            char set1 = set12(teamA, teamB, set);
             if (set1=='A')
             {
                cout <<"\n+++++++++ Set to Team A " << teamA <<" +++++++++ "<< endl;
                cout << "Team A " << teamA << " at set count"<<set<<" to Team B " << teamB << " at set count"<<set<< endl<<endl;
                aScore++;
             }
             else
             {
                cout <<"\n+++++++++ Set to Team B " << teamB <<" +++++++++ " << endl;
                cout << "Team B " << teamB << " at set count "<<set<<" to Team A " << teamA << " a set count "<<set<< endl<<endl;
                bScore++;
             }
             //Set 2 status.
            set++;
            char set2 = set12(teamA, teamB, set);
             if (set2 =='A')
             {
                cout <<"\n+++++++++ Set to Team A " << teamA <<" +++++++++ "<< endl;
                cout << "Team A " << teamA << " at set count"<<set<<" to Team B " << teamB << " at set count"<<set<< endl<<endl;
                aScore++;
             }
             else
             {
                cout <<"\n+++++++++ Set to Team B " << teamB <<" +++++++++ " << endl;
                cout << "Team B " << teamB << " at set count "<<set<<" to Team A " << teamA << " a set count "<<set<< endl<<endl;
                bScore++;
             }
    		set++;
    	if (aScore ==2 && bScore ==1) 
        	
    		cout << "Tie breaker required !!!";
        	tie();
       
    
        	
        if (aScore==0 || bScore==0)
        	cout << "Would you like to play again? (Y/N)? ";
        cin >> yn;
        }while(yn !='n' && yn !='N');
         
        cin.get();
    
    	
        return 0;
    }
    
    char set12(char teamA[21], char teamB[21], int set)
    {
        int aPoints = 0;
        int bPoints = 0;
        int totalPoints = 0;
        int win = 21;
        bool winner=false;
        bool tie=false;
        bool side=true;
        char point;
        do{
         
          if(side)
            {
            cout << " Current Status   Set " << set << endl;
            cout << setw(20) << right << " Team A " << teamA << " | " << "Team B " << teamB << endl;
            cout << setw(20) << right << "        " << aPoints << " | " << "        " << bPoints << endl;
             
            }
            else
            {
            cout << " Current Status   Set " << set << endl;
            cout << setw(20) << right << " Team B " << teamB << " | " << "Team A " << teamA << endl;
            cout << setw(20) << right << "        " << bPoints << " | " << "        " << aPoints << endl;
            }
          
            do
            {
                cout << "What team scored a point (A or B)? ";
                cin >> point;
            }   while(point != 'a' && point != 'A' && point != 'b' && point != 'B');
             
            if(point == 'a' || point == 'A')
                {
                    aPoints++;
                    totalPoints++;
                }
            else
                {
                    bPoints++;
                    totalPoints++;
                }
         
            if (totalPoints%7==0)
            {
               cout << endl << endl << "Switch Sides!!!" << endl;
               side=!side;
            }
         
        if(aPoints >= 21 && aPoints-bPoints >=2)
                {
                    winner=true;
                    return 'A';
                }
        else if(bPoints >=21 && bPoints-aPoints >1)
                {
                    winner=true;
                    return 'B';
                }
                
                 
         }while (!winner);     
    }
    float tie()
    
    
    
    {
    	char tie(char teamA[16], char teamB[16], int set);
        int aPoints = 0;
        int bPoints = 0;
        int totalPoints = 0;
        int tiewinner = 16;
    	int set=3;
        bool side=true;
        char point;
        char teamA,teamB;
    	
        do{   //current status of set.
            if  (set==3)
            {
            cout << " \nCurrent Status Set Tie Breaker " << setw(7)<<right<< set << endl;
            cout << " Team A " << setw(20) << right  <<teamA<<" | " << " Team B " << setw(20) << right << teamB << endl;
            cout << setw(28) << right << aPoints << " | " << setw(28) << right << bPoints << endl;
             
            }
            else
            {
            cout << " \nCurrent Status Set Tie Breaker " << setw(7)<<right<< set << endl;
            cout << " Team B " << setw(20) << right  <<teamB<<" | " << " Team A " << setw(20) << right << teamA << endl;
            cout << setw(28) << right << bPoints << " | " << setw(28) << right << aPoints << endl;
            }
              do
            {
                cout << "What team scored a point (A or B)? ";
                cin >> point;
              }   while(point != 'a' && point != 'A' && point != 'b' && point != 'B');
             
            if(point == 'a' || point == 'A')
                {
                    aPoints++;
                    totalPoints++;
                }
            else
                {
                    bPoints++;
                    totalPoints++;
                }
              
    		    
         //Switch sides during tie set after 5.
             	if (totalPoints==6 || totalPoints==16 )
            {
                cout << endl << endl << "Switch Sides!!!" << endl;
               side=!side;
            }
         
        if(aPoints >= 16 && aPoints-bPoints >=2)
                {
                    tiewinner=true;
                    return 'A';
                }
        else if(bPoints >=16 && bPoints-aPoints >=2)
                {
                    tiewinner=true;
                    return 'B';
                }
                 
         }while (!tiewinner);     
    }

  6. #6
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,812

    Re: Game tracker stress

    Code:
    int bScore;
    int aScore;
    You are not initialising bScore and aScore. They will have an unknown value at the start of the program.

    Code:
    float tie()
    {
        char tie(char teamA[16], char teamB[16], int set);
        int aPoints = 0;
    This doesn't look right as you are declaring a forward function tie within a function tie() ??
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.2.5)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)