Exemple #1
0
 public TennisGame()
 {
     this.HomePlayer = new TennisPlayer()
     {
         TennisPlayerType   = TennisPlayerType.HomePlayer,
         TennisCurrentScore = TennisScore.Love
     };
     this.AwayPlayer = new TennisPlayer()
     {
         TennisPlayerType   = TennisPlayerType.AwayPlayer,
         TennisCurrentScore = TennisScore.Love
     };
 }
Exemple #2
0
        private TennisScore PlayerScore(TennisPlayer tennisPlayer, TennisScore opponentScore, TennisPlayerType winnerPlayerType)
        {
            TennisScore playerCurrentScore = tennisPlayer.TennisCurrentScore;

            if (tennisPlayer.TennisPlayerType == winnerPlayerType)
            {
                if (tennisPlayer.TennisCurrentScore == TennisScore.Love)
                {
                    playerCurrentScore = TennisScore.Fiften;
                }
                else if (tennisPlayer.TennisCurrentScore == TennisScore.Fiften)
                {
                    playerCurrentScore = TennisScore.Thirty;
                }
                else if (tennisPlayer.TennisCurrentScore == TennisScore.Thirty)
                {
                    playerCurrentScore = TennisScore.Forty;
                }
                else if (tennisPlayer.TennisCurrentScore == TennisScore.Forty &&
                         opponentScore == TennisScore.Adv)
                {   //Adv_Adv ==> deuce
                    playerCurrentScore = TennisScore.Forty;
                }
                else if (tennisPlayer.TennisCurrentScore == TennisScore.Forty)
                {
                    playerCurrentScore = TennisScore.Adv;
                }
                else if (tennisPlayer.TennisCurrentScore == TennisScore.Adv)
                {
                    playerCurrentScore = TennisScore.Win;
                }
            }
            else
            {
                if (tennisPlayer.TennisCurrentScore == TennisScore.Adv &&
                    opponentScore == TennisScore.Forty)
                {   //Adv_Adv ==> deuce
                    playerCurrentScore = TennisScore.Forty;
                }
            }
            return(playerCurrentScore);
        }
Exemple #3
0
 public TennisGame(TennisPlayer homePlayer, TennisPlayer awayPlayer)
 {
     this.HomePlayer = homePlayer;
     this.AwayPlayer = awayPlayer;
 }