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));
        }
Exemple #5
0
 public TennisGame GetNextGame(ITournamentRules tournamentRules)
 {
     throw new InvalidOperationException("There are no more games in this set.");
 }
Exemple #6
0
        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);
        }
Exemple #7
0
 public abstract TennisGame GetNextGame(ITournamentRules tournamentRules);
Exemple #8
0
 public override TennisGame GetNextGame(ITournamentRules tournamentRules)
 {
     return new TennisGame(Set.PartyA, Set.PartyB, tournamentRules.GetStandardGameState);
 }
Exemple #9
0
 public override TennisSet GetNextSet(ITournamentRules tournamentRules)
 {
     throw new InvalidOperationException("There are no more sets in this match.");
 }
Exemple #10
0
        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 TennisGame GetNextGame(ITournamentRules tournamentRules)
 {
     throw new InvalidOperationException("There are no more games in this set.");
 }
 public override TennisSet GetNextSet(ITournamentRules tournamentRules)
 {
     throw new InvalidOperationException("There are no more sets in this match.");
 }
 public abstract TennisGame GetNextGame(ITournamentRules tournamentRules);
 public abstract TennisSet GetNextSet(ITournamentRules tournamentRules);
Exemple #15
0
 public TennisMatch(ITournamentRules tournamentRules, Func<TennisMatch, IMatchState> matchStateFactory)
     : base(new Party("A"), new Party("B"))
 {
     _tournamentRules = tournamentRules;
     _matchState = matchStateFactory(this);
     _currentSet = _matchState.GetNextSet(tournamentRules);
 }
Exemple #16
0
 public abstract TennisSet GetNextSet(ITournamentRules tournamentRules);
Exemple #17
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);
 }
 public override TennisGame GetNextGame(ITournamentRules tournamentRules)
 {
     return(new TennisGame(Set.PartyA, Set.PartyB, tournamentRules.GetStandardGameState));
 }