static void Main(string[] args) { var tennisGame = new TennisGame(); tennisGame.PlayTennis(); Console.ReadKey(); }
public void RealisticTennisGame(TennisGame game) { String[] points = {"player1", "player1", "player2", "player2", "player1", "player1"}; String[] expected_scores = {"Fifteen-Love", "Thirty-Love", "Thirty-Fifteen", "Thirty-All", "Forty-Thirty", "Win for player1"}; for (int i = 0; i < 6; i++) { game.WonPoint(points[i]); Assert.AreEqual(expected_scores[i], game.GetScore()); } }
public void RealisticTennisGame(TennisGame game) { String[] points = { "player1", "player1", "player2", "player2", "player1", "player1" }; String[] expected_scores = { "Fifteen-Love", "Thirty-Love", "Thirty-Fifteen", "Thirty-All", "Forty-Thirty", "Win for player1" }; for (int i = 0; i < 6; i++) { game.WonPoint(points[i]); Assert.AreEqual(expected_scores[i], game.GetScore()); } }
public void checkAllScores(TennisGame game) { int highestScore = Math.Max(this.player1Score, this.player2Score); for (int i = 0; i < highestScore; i++) { if (i < this.player1Score) game.WonPoint("player1"); if (i < this.player2Score) game.WonPoint("player2"); } Assert.AreEqual(this.expectedScore, game.GetScore()); }
public void Convert_Points_To_Score( int player1Points, int player2Points, string expected) { // Giwen var game = new TennisGame(player1Points, player2Points); // When var score = game.GetScore(); // Then Assert.Equal(expected, score); }
public void CheckRealisticGame() { var game = new TennisGame("player1", "player2"); string[] points = { "player1", "player1", "player2", "player2", "player1", "player1" }; string[] expectedScores = { "Fifteen-Love", "Thirty-Love", "Thirty-Fifteen", "Thirty-All", "Forty-Thirty", "Win for player1" }; for (var i = 0; i < 6; i++) { game.WonPoint(game.PlayerList.First(p => p.Name == points[i]).Id, game.PlayerList.First(p => p.Name != points[i]).Id); Assert.AreEqual(expectedScores[i], game.GetScore()); } }
public void CheckRealisticGame() { var game = new TennisGame("player1", "player2"); string[] points = { "player1", "player1", "player2", "player2", "player1", "player1" }; string[] expectedScores = { "Fifteen-Love", "Thirty-Love", "Thirty-Fifteen", "Thirty-All", "Forty-Thirty", "Win for player1" }; for (var i = 0; i < 6; i++) { game.PointScored(points[i] == "player1" ? game.PlayerOne : game.PlayerTwo); Assert.AreEqual(expectedScores[i], game.GetGameScore()); } }
public void checkAllScores(TennisGame game) { int highestScore = Math.Max(this.player1Score, this.player2Score); for (int i = 0; i < highestScore; i++) { if (i < this.player1Score) { game.WonPoint("player1"); } if (i < this.player2Score) { game.WonPoint("player2"); } } Assert.AreEqual(this.expectedScore, game.GetScore()); }
public void AssertTennisScore(int player1Score, int player2Score, string expectedScore) { var game = new TennisGame("player1", "player2"); var highestScore = Math.Max(player1Score, player2Score); for (var i = 0; i < highestScore; i++) { if (i < player1Score) { game.WonPoint("player1"); } if (i < player2Score) { game.WonPoint("player2"); } } Assert.AreEqual(expectedScore, game.GetScore()); }
//Game Creation private void Button_Click_1(object sender, RoutedEventArgs e) { game = new TennisGame(First_Player.Text, Second_Player.Text); Player_1_Up.IsEnabled = true; Player_2_Up.IsEnabled = true; Player1_Name1.Content = game.Player_1().Name(); Player1_Name2.Content = game.Player_1().Name(); Player2_Name1.Content = game.Player_2().Name(); Player2_Name2.Content = game.Player_2().Name(); foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(ViewPanel)) { (window as ViewPanel).Player1_Name_small.Content = game.Player_1().Name(); (window as ViewPanel).Player2_Name_small.Content = game.Player_2().Name(); } } UpdateAll(); }
public void CheckTennisGame(int player1Score, int player2Score, string expectedScore) { var game = new TennisGame("player1", "player2"); var highestScore = Math.Max(player1Score, player2Score); for (var i = 0; i < highestScore; i++) { if (i < player1Score) { game.PointScored(game.PlayerOne); } if (i < player2Score) { game.PointScored(game.PlayerTwo); } } Assert.AreEqual(expectedScore, game.GetGameScore()); }
public void CheckTennisGame(int player1Score, int player2Score, string expectedScore) { var game = new TennisGame("player1", "player2"); var p1 = game.PlayerList.First(p => p.Name == "player1"); var p2 = game.PlayerList.First(p => p.Name == "player2"); var highestScore = Math.Max(player1Score, player2Score); for (var i = 0; i < highestScore; i++) { if (i < player1Score) { game.WonPoint(p1.Id, p2.Id); } if (i < player2Score) { game.WonPoint(p2.Id, p1.Id); } } Assert.AreEqual(expectedScore, game.GetScore()); }
public static void Main(string[] args) { TennisGame game = new TennisGame("GZ", "CNN"); game.FirstPlayerScore(); game.Score(); game.SecondPlayerScore(); game.Score(); game.FirstPlayerScore(); game.FirstPlayerScore(); game.SecondPlayerScore(); game.SecondPlayerScore(); game.Score(); game.SecondPlayerScore(); game.Score(); game.SecondPlayerScore(); game.Score(); }
public GameStateWon(TennisGame game, Party winningParty) : base(game) { _winningParty = winningParty; }
public GameStateAdvantageScoring(TennisGame game) : base(game) { }
static void Main(string[] args) { TennisGame tennisGame = new TennisGame(); Console.WriteLine(tennisGame.GetScore("Federer", "Nadal", 2, 1)); }
public IGameState GetNormalGameState(TennisGame game) { return new GameStateSimpleNoAdScoring(game); }
public IGameState GetStandardGameState(TennisGame game) { return new GameStateAdvantageScoring(game); }
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 GameStateAdvantage(TennisGame game, Party advantageParty) : base(game) { _advantageParty = advantageParty; }
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 Teardown() { tennis = null; }
protected GameStateBase(TennisGame game) { Game = game; }
public void CheckTennisGame() { var game = new TennisGame("player1", "player2"); CheckAllScores(game); }
public GameStateDeuce(TennisGame game) : base(game) { }
public GameStateSimpleNoAdScoring(TennisGame game) : base(game) { }
public void Setup() { tennis = new Tennis.TennisGame("Federer", "Nadal"); }
public void CheckGame() { var game = new TennisGame("player1", "player2"); RealisticTennisGame(game); }
public GameStateTieBreakScoring(TennisGame game) : base(game) { }