static void Main(string[] args) { Write("Play or Sim? (p for play and s for sim): "); var tempChar = char.Parse(ReadLine()); if (tempChar == 's') { Write("How many innings? "); var tempInt = int.Parse(ReadLine()); RunSim(tempInt); } Player[] playerArr = new Player[9]; for (int i = 0; i < playerArr.Length; ++i) { playerArr[i] = new Player(i); } Pitcher pitcher = new Pitcher(); AtBat atbat = new AtBat(); atbat.AtBatIN(shuffleArray(playerArr), pitcher); Read(); }
private static void RunSim(int iterations) { int totalRuns = 0; //add more data here Player[] playerArr = new Player[9]; for (int i = 0; i < playerArr.Length; ++i) { playerArr[i] = new Player(i); } Pitcher pitcher = new Pitcher(); for (int i = 0; i < iterations; ++i) { AtBat atbat = new AtBat(); atbat.atBatSim(shuffleArray(playerArr), pitcher); //get values from the at bat object and add them to running totals totalRuns += atbat.Score; } WriteLine("Total number of runs scored in {0} innings is {1}", iterations, totalRuns); Read(); }