Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void AnimauxCroise(Ferme p_Ferme)
- {
- Ferme dejaTeste = new Ferme();
- foreach (Animal animalA in p_Ferme)
- {
- foreach (Animal animalB in p_Ferme)
- {
- if (!animalB.Equals(animalA))
- {
- // On regarde si l'animal qu'on veut tester n'a pas déjà été testé
- bool tested = false;
- foreach (Animal deja in dejaTeste)
- {
- tested = tested || deja.Equals(animalB);
- }
- if (!tested)
- {
- DateTime mortA = animalA.Arrivée.Add(animalA.Age);
- DateTime mortB = animalB.Arrivée.Add(animalB.Age);
- if ((mortB.CompareTo(animalA.Arrivée) >= 0 && mortB.CompareTo(mortA) <= 0) ||
- (mortA.CompareTo(animalB.Arrivée) >= 0 && mortA.CompareTo(mortB) <= 0))
- {
- Console.Out.WriteLine(animalA.Nom + " a croisé " + animalB.Nom);
- }
- }
- }
- }
- dejaTeste.Ajouter(animalA);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement