Esempio n. 1
0
        public Inning GetPopulatedInning(int number, bool top)
        {
            Inning inning        = new Inning(number, top);
            int    currentBatter = 0;

            foreach (Pitch pitch in InningPitches(inning))
            {
                if (currentBatter != pitch.batter_id)
                {
                    //set the current batter to new batter
                    currentBatter = pitch.batter_id;
                    //query for all of the picthes in the at bat
                    var PitchesInAtBat = (from inningPitch in InningPitches(inning) where inningPitch.batter_id == currentBatter select inningPitch);
                    //adds pitch number for the atBat
                    int ab_counter = 1;
                    foreach (Pitch ab_pitch in PitchesInAtBat)
                    {
                        ab_pitch.at_bat_pitch = ab_counter;
                        ab_counter++;
                    }
                    Pitcher c_pitcher = new Pitcher(pitch.pitcher, pitch.pitcher_id);
                    Batter  c_batter  = new Batter(pitch.batter, pitch.batter_id);
                    //instantiates new at bat
                    AtBat newAB = new AtBat(c_pitcher, c_batter, PitchesInAtBat.ToList());
                    //Add the at bat to the inning
                    inning.AtBats.Add(newAB);
                }
            }
            return(inning);
        }
Esempio n. 2
0
 public AtBat(Pitcher pitcher, Batter batter, List <Pitch> pitches)
 {
     Pitcher = pitcher;
     Batter  = batter;
     Pitches = pitches;
 }