public Lapin Gagnant() { Lapin gagnant = null; for (int i = 1; i < participer.Count; i++) { if (participer[i - 1].Position > participer[i].Position) { gagnant = participer[i - 1]; } } return(gagnant); }
static void Main() { Lapin.ChangeStart(200); Course marathon = new Course(42); marathon.Add(new Lapin("jeannot", 2)); marathon.Add(new Lapin("panpan", 6)); marathon.Add(new Lapin("jelly", 5)); marathon.Départ(); foreach (Lapin l in marathon.Participer) { Console.WriteLine(l.ToString()); } Lapin andTheWinnerIs = marathon.Gagnant(); Console.WriteLine("Le grand gagnant est : {0}", andTheWinnerIs.Surnom); Console.ReadLine(); }
public void Add(Lapin nouveauParticipant) { this.participer.Add(nouveauParticipant); }