week1/RpsGameNoDB/Match.cs
//used to check for wins; returns winner, returns null if no winner yet
/// <summary>
/// This method checks if there is a winner yet. Two round wins are required to win the match. If there is no winner yet, the method will return null.
/// </summary>
/// <returns>bool gameIsOver</returns>
This method checks if there is a winner yet. Two round wins are required to win the match. If there is no winner yet, the method will return null.
This method checks if there is a winner yet . Two round wins are required to win the match . If there is no winner yet the method will return null .
public bool CheckWins(){
            Player winner  = null;
            int p1Wins = 0;
            int p2Wins = 0;
            foreach (Round round in Rounds){
                if(round.WinningPlayer == Player1){
                    p1Wins++;
                }
                else if(round.WinningPlayer == Player2){
                    p2Wins++;
                }
            }
            if(p1Wins>=2){
                winner = Player1;
                return true;
            }
            else if(p2Wins>=2){
                winner = Player2;
                return true;
            }
            return false;
        }
public bool CheckWins ( ) { Player winner = null ; int p1Wins = 0 ; int p2Wins = 0 ; foreach ( Round round in Rounds ) { if ( round . WinningPlayer == Player1 ) { p1Wins ++ ; } else if ( round . WinningPlayer == Player2 ) { p2Wins ++ ; } } if ( p1Wins >= 2 ) { winner = Player1 ; return true ; } else if ( p2Wins >= 2 ) { winner = Player2 ; return true ; } return false ; }
This method checks if there is a winner yet.
This method checks if there is a winner yet .
None