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 TennisMatch(ITournamentRules tournamentRules, Func <TennisMatch, IMatchState> matchStateFactory) : base(new Party("A"), new Party("B")) { _tournamentRules = tournamentRules; _matchState = matchStateFactory(this); _currentSet = _matchState.GetNextSet(tournamentRules); }
public override TennisSet GetNextSet(ITournamentRules tournamentRules) { Func <TennisSet, ISetState> setStateFactory = tournamentRules.GetStandardSetState; if (Match.ScoreA == 2 && Match.ScoreB == 2) { setStateFactory = tournamentRules.GetDecidingSetState; } return(new TennisSet(tournamentRules, Match.PartyA, Match.PartyB, setStateFactory)); }
public override TennisGame GetNextGame(ITournamentRules tournamentRules) { Func <TennisGame, IGameState> gameStateFactory = tournamentRules.GetStandardGameState; if (Set.ScoreA == 6 && Set.ScoreB == 6) { gameStateFactory = game => new GameStateTieBreakScoring(game); } return(new TennisGame(Set.PartyA, Set.PartyB, gameStateFactory)); }
public TennisGame GetNextGame(ITournamentRules tournamentRules) { throw new InvalidOperationException("There are no more games in this set."); }
public override TennisGame GetNextGame(ITournamentRules tournamentRules) { Func<TennisGame, IGameState> gameStateFactory = tournamentRules.GetStandardGameState; if (Set.ScoreA == 6 && Set.ScoreB == 6) { gameStateFactory = game => new GameStateTieBreakScoring(game); } return new TennisGame(Set.PartyA, Set.PartyB, gameStateFactory); }
public abstract TennisGame GetNextGame(ITournamentRules tournamentRules);
public override TennisGame GetNextGame(ITournamentRules tournamentRules) { return new TennisGame(Set.PartyA, Set.PartyB, tournamentRules.GetStandardGameState); }
public override TennisSet GetNextSet(ITournamentRules tournamentRules) { throw new InvalidOperationException("There are no more sets in this match."); }
public override TennisSet GetNextSet(ITournamentRules tournamentRules) { Func<TennisSet, ISetState> setStateFactory = tournamentRules.GetStandardSetState; if (Match.ScoreA == 2 && Match.ScoreB == 2) setStateFactory = tournamentRules.GetDecidingSetState; return new TennisSet(tournamentRules, Match.PartyA, Match.PartyB, setStateFactory); }
public abstract TennisSet GetNextSet(ITournamentRules tournamentRules);
public TennisMatch(ITournamentRules tournamentRules, Func<TennisMatch, IMatchState> matchStateFactory) : base(new Party("A"), new Party("B")) { _tournamentRules = tournamentRules; _matchState = matchStateFactory(this); _currentSet = _matchState.GetNextSet(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); }
public override TennisGame GetNextGame(ITournamentRules tournamentRules) { return(new TennisGame(Set.PartyA, Set.PartyB, tournamentRules.GetStandardGameState)); }