public virtual List <NascarRaceLap> UpdateRaceLaps(List <NascarRaceLap> lastLaps, LapState state) { List <NascarRaceLap> newLaps = null; switch (state) { case LapState.OneToGreenFlag: { newLaps = OneToGoLaps(lastLaps); break; } case LapState.GreenFlag: { newLaps = GreenFlagLaps(lastLaps); break; } case LapState.CautionFlag: { newLaps = CautionLaps(lastLaps); break; } default: { throw new ArgumentException($"Invalid LapState: {state.ToString()}"); } } PrintStandings(newLaps, state); return(newLaps); }
protected virtual void PrintStandings(List <NascarRaceLap> raceLaps, LapState state) { Console.WriteLine($"End of Lap {raceLaps[0].LapNumber} {state.ToString()}"); Console.WriteLine(); Console.WriteLine($" Delta Delta Laps Lap Lap Total Delta Actual Lucky Leader Lap"); Console.WriteLine($" [CAR] Next Leader Down Time Speed Elapsed Physical Delta Pit Dog Lap Number"); for (int x = 0; x < raceLaps.Count; x++) { var rl = raceLaps[x]; Console.WriteLine($"{String.Format("{0,-2}", rl.Position)} - [{String.Format("{0,2}", rl.VehicleId)}] {String.Format("{0,7}", rl.Delta < 0 ? rl.Delta.ToString("####") : rl.Delta.ToString("##.##0"))} {String.Format("{0,7}", rl.DeltaLeader < 0 ? rl.DeltaLeader.ToString("####") : rl.DeltaLeader.ToString("##.##0"))} {(rl.IsLeadLap ? " " : String.Format("{0,-2}", rl.LeaderLap - rl.LapNumber))} {String.Format("{0,8}", rl.LapTime.ToString("###.##0"))} {String.Format("{0,8}", rl.LapSpeed.ToString("###.##0"))} {String.Format("{0,8}", rl.TotalTime.ToString("######.##0"))} {String.Format("{0, 8}", rl.DeltaPhysical.ToString("######.##0"))} {String.Format("{0, 8}", rl.DeltaTravelledLeader.ToString("######.##0"))} {(rl.PitInLap && rl.PitOutLap ? "Pit In " : rl.PitOutLap ? "Pit Out " : "- ")} {(rl.IsLuckyDog ? "Lucky Dog" : "- ")} {rl.LeaderLap} {rl.LapNumber}"); }