Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // Tennis Game 1
            _game1Player1 = "player1";
            _game1Player2 = "player2";

            _tennisScoreBoardGame1 = new TennisScoreBoard(_game1Player1, _game1Player2);
            _tennisScoreBoardGame1.SetPlayerThatHasGarminWatch(_game1Player1);

            // Tennis Game 1
            _game2Player1 = "player1";
            _game2Player2 = "player2";

            _tennisScoreBoardGame2 = new TennisScoreBoard(_game2Player1, _game2Player2);
            _tennisScoreBoardGame2.SetPlayerThatHasGarminWatch(_game2Player2);

            // Start games
            Task.Run(() =>
            {
                var task1 = startGame1();
                var task2 = startGame2();

                Task.WaitAll(task1, task2);
            });

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        private static async Task PlayGame(TennisScoreBoard board, IEnumerable<string> wonPoints, string gameName)
        {
            board.GetScore().WriteLine(gameName + ": {0}");

            foreach (var pointWinner in wonPoints)
            {
                var player = pointWinner;

                await Task.Run(() =>
                {
                    var rdn = new Random();
                    Task.Delay((rdn.Next(1, 6)*1000)).Wait();

                    board.WonPoint(player);
                    board.GetScore().WriteLine(gameName + ": {0}");
                });
            }
        }
 public TennisScoreBoardTests()
 {
     _scoreBoard = new TennisScoreBoard("player1", "player2");
 }