Exemplo n.º 1
0
        public void initializeGame(String HomeTeamName, String AwayTeamName)
        {
            TodayGame = new Game();

               HomeTeam =  TodayGame.PopulateTeam(Team.TeamType.Home);
               HomeTeam.Name = HomeTeamName;
               AwayTeam = TodayGame.PopulateTeam(Team.TeamType.Away);
               AwayTeam.Name = AwayTeamName;

               //assign teams to the game reference pointers
               TodayGame.HomeTeam = HomeTeam;
               TodayGame.AwayTeam = AwayTeam;

               TodayGame.CurrentInning = new Inning();
               TodayGame.CurrentInning.InningNumber = 1.0;
               TodayGame.CurrentInning.HalfInning = Team.TeamType.Home;
        }
Exemplo n.º 2
0
        public String SaveScores(Game TodayGame)
        {
            try
              {

            String filename = "c:\\temp\\GameScores-" + DateTime.Now.ToString("yyyyMMddTHHmmss") + ".txt";
            StreamWriter Writer = new StreamWriter(filename, true);
            Writer.WriteLine("Scores for game on: " + DateTime.Now.ToString("DD-MM-YYYY HH:MM") + Environment.NewLine);
            Writer.WriteLine("*************************************************************************************************************" + Environment.NewLine);
            Writer.WriteLine("Home Team: " + TodayGame.HomeTeam.Name + Environment.NewLine);
            Writer.WriteLine("______________________________________________" + Environment.NewLine);
            Writer.WriteLine("|PLayer Name|At Bats|Hits|Batting Average|OBP|" + Environment.NewLine);
            Writer.WriteLine("______________________________________________" + Environment.NewLine);

            foreach (Player Pl in TodayGame.HomeTeam.TeamPlayers)
            {
                Writer.Write("|" + Pl.Name + "|" + Pl.AtBat + "|" + Pl.Hits + "|" + Pl.BattingAVG + "|" + Pl.OBP + "|" + Environment.NewLine);
                Writer.WriteLine("______________________________________________" + Environment.NewLine);
            }

            Writer.WriteLine("*************************************************************************************************************" + Environment.NewLine);
            Writer.WriteLine("Away Team: " + TodayGame.AwayTeam.Name + Environment.NewLine);
            Writer.WriteLine("______________________________________________" + Environment.NewLine);
            Writer.WriteLine("|PLayer Name|At Bats|Hits|Batting Average|OBP|" + Environment.NewLine);
            Writer.WriteLine("______________________________________________" + Environment.NewLine);

            foreach (Player Pl in TodayGame.AwayTeam.TeamPlayers)
            {
                Writer.Write("|" + Pl.Name + "|" + Pl.AtBat + "|" + Pl.Hits + "|" + Pl.BattingAVG + "|" + Pl.OBP + "|" + Environment.NewLine);
                Writer.WriteLine("______________________________________________" + Environment.NewLine);
            }

            Writer.Close();
            return "Scores saved to file: " + filename;

              }
              catch (Exception e)
              {
              Console.WriteLine(e.Message);
              return "Error occured - " + e.Message;
              }
        }
Exemplo n.º 3
0
        public void updateMultisimStats(Game game)
        {
            iterations++;
            home = game.HomeTeam;
            away = game.AwayTeam;
            homeOrder = game.homeOrder;
            awayOrder = game.awayOrder;

            homeRuns += game.hRuns;
            homeAVGRuns = homeRuns/iterations;
            awayRuns += game.aRuns;
            awayAVGRuns = awayRuns/iterations;

            if (game.hRuns > game.aRuns)
            homeWins++;
            else
            awayWins++;

            homeAVGWins = homeWins/iterations;
            awayAVGWins = awayWins/iterations;

            updateHomeStats();
            updateAwayStats();
        }