예제 #1
0
        public Form1()
        {
            InitializeComponent();
            fGames = new List <Game <Football> >();
            bGames = new List <Game <Basketball> >();


            //TEMP GAMES
            //BASKETBALL
            Basketball            detailsHome = new Basketball();
            Details <int, String> detail1     = new Details <int, string>();

            detail1.key             = 30;
            detail1.value           = "Kobe Bryant";
            detailsHome.gameDetails = new List <Details <int, string> >();
            detailsHome.gameDetails.Add(detail1);

            Basketball            detailsAway = new Basketball();
            Details <int, String> detail2     = new Details <int, string>();

            detail2.key             = 25;
            detail2.value           = "Rajon Rondo";
            detailsAway.gameDetails = new List <Details <int, string> >();
            detailsAway.gameDetails.Add(detail2);

            DateTime date = new DateTime();

            Game <Basketball> bGame = new Game <Basketball>("LA Lakers", "NO Pelicans", 30, 25, detailsHome, detailsAway, date);

            bGames.Add(bGame);

            //FOOTBALL
            Football detailsHome2            = new Football();
            Details <String, String> detail3 = new Details <String, String>();

            detail3.key              = "25min";
            detail3.value            = "Sergio Ramos";
            detailsHome2.gameDetails = new List <Details <String, String> >();
            detailsHome2.gameDetails.Add(detail3);

            Football detailsAway2            = new Football();
            Details <String, String> detail4 = new Details <String, String>();

            detail4.key              = "55min";
            detail4.value            = "Lionel Messi";
            detailsAway2.gameDetails = new List <Details <String, String> >();
            detailsAway2.gameDetails.Add(detail4);

            DateTime date2 = new DateTime();

            Game <Football> fGame = new Game <Football>("Real Madrid", "Barcelona", 1, 1, detailsHome2, detailsAway2, date);

            fGames.Add(fGame);
            //

            footballListBox.DataSource   = fGames;
            basketballListBox.DataSource = bGames;
        }
예제 #2
0
    //使用 Game 的模板方法 play() 来演示游戏的定义方式。
    public void Main()
    {
        Game game = new Cricket();

        game.Play();

        game = new Football();
        game.Play();
    }
예제 #3
0
        public void Test_is_valid_with_valid_football_returns_true(Football football)
        {
            // Arrange.
            // Act.
            var result = football.IsValid();

            // Assert.
            result.IsValid.Should().BeTrue("the football data is all made up of valid data.");
        }
예제 #4
0
        static void Main(string[] args)
        {
            Game game = new Cricket();

            game.Play();
            Console.WriteLine();
            game = new Football();
            game.Play();
        }
예제 #5
0
        public void Test_validate_with_good_data_returns_true(Football football)
        {
            // Arrange.
            // Act.
            var result = _footballValidator.Validate(football);

            // Assert.
            result.IsValid.Should().BeTrue("the football data is all made up of valid data.");
        }
        private async void Update(Football football, int id)
        {
            updateButton.Enabled = false;
            football.EventId     = id;

            HttpResponseMessage footballMessage = await RestService.Post(football, "football/update");

            updateButton.Enabled = true;
        }
예제 #7
0
        public void Test_is_valid_with_invalid_football_returns_false(Football football)
        {
            // Arrange.
            // Act.
            var result = football.IsValid(new FootballValidator());

            // Assert.
            result.IsValid.Should().BeFalse("the football data is made up of invalid data.");
        }
예제 #8
0
        private async void AddButton_Click(object sender, EventArgs e)
        {
            if (awayTeamName.Text.Length > 0 && homeTeamName.Text.Length > 0 && tournamentName.Text.Length > 0)
            {
                Event ev = new Event();

                ev.HostName       = homeTeamName.Text;
                ev.GuestName      = awayTeamName.Text;
                ev.TournamentName = tournamentName.Text;

                HttpResponseMessage message = await RestService.Post(ev, "event/create");

                string msg = await message.Content.ReadAsStringAsync();

                ev = JsonConvert.DeserializeObject <Event>(msg);

                if (sportType1.Checked == true)
                {
                    Football football = new Football();

                    football.EventId = ev.Id;

                    HttpResponseMessage footballMessage = await RestService.Post(football, "football/create");
                }
                else if (sportType2.Checked == true)
                {
                    Volleyball volleyball = new Volleyball();

                    volleyball.EventId = ev.Id;

                    HttpResponseMessage volleyballMessage = await RestService.Post(volleyball, "volleyball/create");
                }
                else if (sportType3.Checked == true)
                {
                    Tennis tennis = new Tennis();

                    tennis.EventId = ev.Id;

                    HttpResponseMessage tennisMessage = await RestService.Post(tennis, "tennis/create");
                }

                var intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
            }
            else
            {
                Android.Support.V7.App.AlertDialog.Builder alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this);
                alertDialog.SetTitle("Info");
                alertDialog.SetMessage("Fields cannot be empty!");
                alertDialog.SetNeutralButton("OK", delegate
                {
                    alertDialog.Dispose();
                });
                alertDialog.Show();
            }
        }
예제 #9
0
        private void btTemplatePattern_Click(object sender, EventArgs e)
        {
            string str  = "";
            Game   game = new Cricket();

            str             += game.play();
            game             = new Football();
            str             += game.play();
            tbOutWindow.Text = str;
        }
예제 #10
0
    protected override void Start()
    {
        base.Start();

        var footballGO = GameObject.FindGameObjectWithTag("Football");

        football = footballGO.GetComponent <Football>();

        football.lureEvent.AddListener(OnLureActive);
    }
예제 #11
0
        static void Main(string[] args)
        {
            Football football = new Football();
            Goal     goal     = new Goal();

            football.GoalArrived += new GoalHandler(goal.Messi);
            football.Connect();

            Console.ReadLine();
        }
        public bool validateFileContent()
        {
            IsFileValid = true;
            bool isLineValid;

            for (int i = 0; i < lstLines.Count; i++)
            {
                if (fileFormatSettings.bIfHeaderInFirstLine && i == 0)
                {
                    continue;
                }

                isLineValid = true;
                string        mesg     = string.Empty;
                string        line     = lstLines[i];
                List <string> lineData = line.Split(fileFormatSettings.sSplitToken.ToCharArray()).ToList();
                lineData = lineData.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();

                ErrorMesage erroMsgObj;

                if (lineData.Count != fileFormatSettings.iTokensPerCol)
                {
                    mesg        = AppConstant.ERROR_TOKEN_COUNT_MISMATCH;;
                    mesg        = string.Format(mesg, fileFormatSettings.iTokensPerCol);
                    isLineValid = false;
                }
                else
                {
                    Football newFootableRecord = new Football(lineData[1], lineData[2], lineData[3], lineData[4], lineData[5], lineData[6], lineData[7], lineData[8], lineData[9]);
                    if (newFootableRecord.isValid)
                    {
                        listFootable.Add(newFootableRecord);
                        isLineValid = true;
                    }
                    else
                    {
                        mesg = AppConstant.ERROR_FIELD_TYPE_MISMATCH;

                        isLineValid = false;
                    }
                }
                if (!isLineValid)
                {
                    IsFileValid = false;
                    erroMsgObj  = new ErrorMesage();
                    erroMsgObj.sErrorMessage = mesg;
                    erroMsgObj.sLineText     = line;
                    erroMsgObj.iCurLineNo    = i;
                    lstErrorMessage.Add(erroMsgObj);
                }
            }

            return(IsFileValid);
        }
예제 #13
0
        static void Main(string[] args)
        {
            Game game = new Football();

            game.Play();
            Console.WriteLine();
            game = new Basketball();
            game.Play();
            Console.WriteLine();
            Console.ReadKey();
        }
예제 #14
0
        public async Task <IActionResult> Create([Bind("FootballID,Name,Price,ProductID")] Football football)
        {
            if (ModelState.IsValid)
            {
                _context.Add(football);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(football));
        }
예제 #15
0
        public void Start()
        {
            logger.Info("Cricket Game: ");
            var cricket = new Cricket();

            cricket.Play();

            logger.Info("Football Game: ");
            var football = new Football();

            football.Play();
        }
예제 #16
0
        public void Test_validate_with_bad_data_returns_false(Football football, int errorCount, List <string> errorMessages)
        {
            // Arrange.
            // Act.
            var result = _footballValidator.Validate(football);

            // Assert.
            // If one fails, then it all should fail.  We will see the 'because' detail.
            result.IsValid.Should().BeFalse("the football data is made up of invalid data.");
            result.Errors.Count.Should().Be(errorCount, "the count should be what I defined.");
            result.Errors.Select(m => m.ErrorMessage).Should().BeEquivalentTo(errorMessages, "the error messages need to match.");
        }
예제 #17
0
        static void Main(string[] args)
        {
            Game game1 = new Cricket();

            game1.Play();
            Console.WriteLine("\n\n");

            Game game2 = new Football();

            game2.Play();
            Console.ReadLine();
        }
예제 #18
0
        public async Task <IActionResult> CreateFootballEvent([FromBody] Football ev)
        {
            try
            {
                _footballRepository.Create(ev);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(Ok(ex));
            }
        }
        public void UpdateGameWithDateTest()
        {
            //Arrange
            Football football = new Football();

            //Act
            List <FootballGame> games = football.UpdateGameWithDate("Spain", "Brazil", 15, 2, new DateTime(1984, 5, 12));

            List <FootballGame> gamesExpected = FootballAserts.UpdateGameWithDateAssert();

            //Assert
            Assert.IsTrue(CompareGamesList(gamesExpected, games));
        }
        public void FinishGameTest()
        {
            //Arrange
            Football football = new Football();

            //Act
            List <FootballGame> games = football.FinishGame("Mexico", "Canada", new DateTime(1985, 5, 12));

            List <FootballGame> gamesExpected = FootballAserts.FinishGameAssert();

            //Assert
            Assert.IsTrue(CompareGamesList(gamesExpected, games));
        }
예제 #21
0
        static void Main(string[] args)
        {
            //Positions
            Position playerPosition = new Position();

            playerPosition.X = 5;
            playerPosition.Y = 10;
            playerPosition.Z = 15;
            Position ballPosition = new Position();

            ballPosition.X = 10;
            ballPosition.Y = 20;
            ballPosition.Z = 30;
            Position newBallPosition = new Position();

            newBallPosition.X = 5;
            newBallPosition.Y = 10;
            newBallPosition.Z = 15;
            Position refreePosition = new Position();

            refreePosition.X = 5;
            refreePosition.Y = 15;
            refreePosition.Z = 25;

            //---------------------------------------BALL----------------------

            Football football = new Football();

            football.Ball_Position = ballPosition;
            //-------------------------------------PLAYER-----------------------
            Player player1 = new Player();

            player1.Player_Name     = "Abo Trika";
            player1.Player_Team     = "Al Ahly";
            player1.Player_Position = playerPosition;

            Console.WriteLine("Before Updating : " + player1.ToString());
            football.Attach(player1);
            football.changePosition(newBallPosition);
            Console.WriteLine("After Updating : " + player1.ToString());
            //------------------------------REFREE---------------------------
            Refree refree1 = new Refree();

            refree1.Refree_Name     = "Al7km";
            refree1.Refree_Position = refreePosition;

            Console.WriteLine("Before Updating : " + refree1.ToString());
            football.Attach(refree1);
            football.changePosition(newBallPosition);
            Console.WriteLine("After Updating : " + refree1.ToString());
        }
예제 #22
0
        static void Main(string[] args)
        {
            #region Template Method
            //RelatorioSimples relatorioSimples = new RelatorioSimples();
            //relatorioSimples.ImprimirRelatorio();
            //Console.ReadKey();

            //Console.Clear();

            //RelatorioComplexo relatorioComplexo = new RelatorioComplexo();
            //relatorioComplexo.ImprimirRelatorio();
            //Console.ReadKey();

            //Console.Clear();
            #endregion


            #region Template Method + Chain of Responsability
            //TipoRelatorio tipo = TipoRelatorio.RelatorioComplexo;

            //RelatorioSimples relatorio = new RelatorioSimples(new RelatorioComplexo());
            //relatorio.ImprimirRelatorio(tipo);
            #endregion

            #region Exemplo Tutorials Point
            Game game = new Cricket();
            game.Play();
            Console.WriteLine();

            /*
             *  Output:
             *      Cricket Game Initialized! Start playing.
             *      Cricket Game Started. Enjoy the game!
             *      Cricket Game Finished!
             */

            game = new Football();
            game.Play();

            /*
             *  Output:
             *      Football Game Initialized! Start playing.
             *      Football Game Started. Enjoy the game!
             *      Football Game Finished!
             */

            #endregion

            Console.ReadKey();
        }
예제 #23
0
        public async Task <IActionResult> UpdateFootballEvent([FromBody] Football ev)
        {
            Football football = new Football();

            try
            {
                football = _footballRepository.Update(ev);

                return(Ok(football));
            }
            catch (Exception ex)
            {
                return(Ok(ex));
            }
        }
        public void UpdateGameScoreLiveTest()
        {
            //Arrange
            Football football = new Football();

            football.StartGame("Senegal", "Marroco");

            //Act
            List <FootballGame> games = football.UpdateGameScoreLive("Senegal", "Marroco", 1, 2);

            List <FootballGame> gamesExpected = FootballAserts.UpdateGameScoreLiveAssert();

            //Assert
            Assert.IsTrue(CompareGamesList(gamesExpected, games));
        }
        private async void GetFootballMatch()
        {
            string footballEventJson = await RestService.Get("football/get/" + footballEventId);

            footballEvent = JsonConvert.DeserializeObject <Football>(footballEventJson);

            FindViews();

            HandleEvents();

            homeTeamName.Text = footballEvent.Event.HostName;
            awayTeamName.Text = footballEvent.Event.GuestName;

            homeTeamScore.Text = footballEvent.HostScore.ToString();
            awayTeamScore.Text = footballEvent.GuestScore.ToString();
        }
예제 #26
0
 public HttpResponseMessage AddAutograph([FromBody] AutographRequest request)
 {
     try
     {
         Football football = library.AddAutograph(request.Id, request.Autograph);
         return(Request.CreateResponse(HttpStatusCode.OK, football));
     }
     catch (FootballFullException e)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, "Football is full!"));
     }
     catch (FootballNotFoundException e)
     {
         return(Request.CreateResponse(HttpStatusCode.NotFound));
     }
 }
        public void StartGameTest()
        {
            //Arrange
            Football football = new Football();

            //Act
            List <FootballGame> games = football.StartGame("Senegal", "Marroco");

            List <FootballGame> gamesExpected = FootballAserts.StartGameAssert();

            //Assert
            Assert.IsTrue(CompareGamesList(gamesExpected, games));

            //I have considered to do it with CollectionAssert.AreEqual, but it compares also the references and it does not work,
            //I also considered to do it with linq instead of the for loop, but the two loops are nested and the result is not correct,
            //at the end I have thought to do that method, I do not know if some other more effective way to do it.
        }
예제 #28
0
        public IList <Football> GetFootballData(string fileLocation)
        {
            // Contract checks.
            if (string.IsNullOrWhiteSpace(fileLocation))
            {
                throw new ArgumentNullException(nameof(fileLocation), "The file location can not be null.");
            }

            var file = _fileSystem.File.ReadAllLines(fileLocation);

            if (!file.Any() || !file.First().Contains(AppConstants.FootballHeader))
            {
                throw new InvalidDataException("Invalid File Data.  No rows found.");
            }

            var results = new List <Football>();

            foreach (var item in file)
            {
                // Need to use the config to extract out the items...
                if (!item.Equals(AppConstants.FootballHeader) && !item.Equals(AppConstants.FootballDivider))
                {
                    // So, not the header and not the divider line.
                    var team          = item.Substring(FootballConfig.TeamColumnStart, FootballConfig.TeamColumnLength);
                    var forPoints     = item.Substring(FootballConfig.ForColumnStart, FootballConfig.ForColumnLength);
                    var againstPoints = item.Substring(FootballConfig.AgainstColumnStart, FootballConfig.AgainstColumnLength);

                    if (int.TryParse(forPoints, out var forAsInt) && int.TryParse(againstPoints, out var againstAsInt))
                    {
                        // So, we parsed the points correctly.
                        var currentFootball = new Football
                        {
                            TeamName      = team.Trim(),
                            ForPoints     = forAsInt,
                            AgainstPoints = againstAsInt
                        };

                        results.Add(currentFootball);
                    }
                }
            }

            return(results);
        }
예제 #29
0
        public void GoTo(string siteLocation)
        {
            string expectedPageTitle;

            switch (siteLocation)
            {
            case "BBCHome":
                BBCHome.Click();
                expectedPageTitle = "BBC - Home";
                break;

            case "NewsHome":
                News.Click();
                expectedPageTitle = "Home - BBC News";
                break;

            case "SportsHome":
                Sport.Click();
                expectedPageTitle = "BBC Sport - Sport";
                break;

            case "FootballHome":
                Football.Click();
                expectedPageTitle = "BBC Sport - Football";
                break;

            default:
                expectedPageTitle = "Unknown location";
                break;
            }

            var wait = Browser.Wait();

            try
            {
                wait.Until(p => p.Title == expectedPageTitle);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw;
            }
        }
예제 #30
0
        private void FindSmallestFAResult()
        {
            List <Football> lstFootableData = curLoadFile.getListData();
            Football        smallRestRecord = null;
            int             smallest        = 0;

            foreach (Football item in lstFootableData)
            {
                int diff = item.F - item.A;
                if (diff < smallest)
                {
                    smallest        = diff;
                    smallRestRecord = item;
                }
            }
            lblTeamResult.Text = smallRestRecord.Team;
            lblFResult.Text    = smallRestRecord.F.ToString();
            lblAResult.Text    = smallRestRecord.A.ToString();
            lblDiffResult.Text = smallest.ToString();
        }