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 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 TennisSet(ITournamentRules tournamentRules, Party partyA, Party partyB, Func<TennisSet, ISetState> setStateFactory) : base(partyA, partyB) { _setState = setStateFactory(this); _tournamentRules = tournamentRules; _currentGame = _setState.GetNextGame(tournamentRules); }