Пример #1
0
 public TennisSet(ITournamentRules tournamentRules, Party partyA, Party partyB, Func <TennisSet, ISetState> setStateFactory)
     : base(partyA, partyB)
 {
     _setState        = setStateFactory(this);
     _tournamentRules = tournamentRules;
     _currentGame     = _setState.GetNextGame(tournamentRules);
 }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
 public TennisSet(ITournamentRules tournamentRules, Party partyA, Party partyB, Func<TennisSet, ISetState> setStateFactory)
     : base(partyA, partyB)
 {
     _setState = setStateFactory(this);
     _tournamentRules = tournamentRules;
     _currentGame = _setState.GetNextGame(tournamentRules);
 }