Exemplo n.º 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);
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
 public TennisGame GetNextGame(ITournamentRules tournamentRules)
 {
     throw new InvalidOperationException("There are no more games in this set.");
 }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
 public abstract TennisGame GetNextGame(ITournamentRules tournamentRules);
Exemplo n.º 8
0
 public override TennisGame GetNextGame(ITournamentRules tournamentRules)
 {
     return new TennisGame(Set.PartyA, Set.PartyB, tournamentRules.GetStandardGameState);
 }
Exemplo n.º 9
0
 public override TennisSet GetNextSet(ITournamentRules tournamentRules)
 {
     throw new InvalidOperationException("There are no more sets in this match.");
 }
Exemplo n.º 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);
        }
Exemplo n.º 11
0
 public TennisGame GetNextGame(ITournamentRules tournamentRules)
 {
     throw new InvalidOperationException("There are no more games in this set.");
 }
Exemplo n.º 12
0
 public override TennisSet GetNextSet(ITournamentRules tournamentRules)
 {
     throw new InvalidOperationException("There are no more sets in this match.");
 }
Exemplo n.º 13
0
 public abstract TennisGame GetNextGame(ITournamentRules tournamentRules);
Exemplo n.º 14
0
 public abstract TennisSet GetNextSet(ITournamentRules tournamentRules);
Exemplo n.º 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);
 }
Exemplo n.º 16
0
 public abstract TennisSet GetNextSet(ITournamentRules tournamentRules);
Exemplo n.º 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);
 }
Exemplo n.º 18
0
 public override TennisGame GetNextGame(ITournamentRules tournamentRules)
 {
     return(new TennisGame(Set.PartyA, Set.PartyB, tournamentRules.GetStandardGameState));
 }