public TennisSet(ITournamentRules tournamentRules, Party partyA, Party partyB, Func <TennisSet, ISetState> setStateFactory)
     : base(partyA, partyB)
 {
     _setState        = setStateFactory(this);
     _tournamentRules = tournamentRules;
     _currentGame     = _setState.GetNextGame(tournamentRules);
 }
        public void AddPoint(Party party)
        {
            if (SetOver)
            {
                throw new InvalidOperationException("Cannot add points to won sets.");
            }

            _currentGame.AddPoint(party);

            if (_currentGame.GameOver)
            {
                IncreaseScore(party);
                _setState = _setState.GameAdded(party);

                if (!_setState.SetOver)
                {
                    _currentGame = _setState.GetNextGame(_tournamentRules);
                }
            }
        }
 public IGameState GetStandardGameState(TennisGame game)
 {
     return(new GameStateAdvantageScoring(game));
 }
 public GameStateWon(TennisGame game, Party winningParty)
     : base(game)
 {
     _winningParty = winningParty;
 }
 public GameStateTieBreakScoring(TennisGame game)
     : base(game)
 {
 }
 public GameStateSimpleNoAdScoring(TennisGame game)
     : base(game)
 {
 }
 public GameStateDeuce(TennisGame game)
     : base(game)
 {
 }
 public GameStateAdvantageScoring(TennisGame game)
     : base(game)
 {
 }
 public GameStateAdvantage(TennisGame game, Party advantageParty)
     : base(game)
 {
     _advantageParty = advantageParty;
 }
 public IGameState GetNormalGameState(TennisGame game)
 {
     return(new GameStateSimpleNoAdScoring(game));
 }
 protected GameStateBase(TennisGame game)
 {
     Game = game;
 }