BattleShip.Core.GameHost.FindOpponentByPlayerEmail C# (CSharp) Method

FindOpponentByPlayerEmail() private method

private FindOpponentByPlayerEmail ( Game game, string playerEmail ) : Player
game Game
playerEmail string
return Player
        private Player FindOpponentByPlayerEmail(Game game, string playerEmail)
        {
            if (game.Player1.Email == playerEmail)
            {
                return game.Player2;
            }

            if (game.Player2.Email == playerEmail)
            {
                return game.Player1;
            }

            throw new InvalidOperationException("No such player.");
        }