public void GaUitBos(int bosID) { int sprongId = VorigeBomen.Count; TijdelijkeBoom.VerwijderAapUitBoom(this); VorigeBomen.Add(sprongId, TijdelijkeBoom); TijdelijkeBoom = null; Console.WriteLine("Aap {0} van bos {1} klaar met springen", Naam, bosID); }
public void Spring(Bos bosWaarAapInIs) { KeyValuePair <double, Boom> pairAfstandEnBoom = bosWaarAapInIs.VindDichtstbijzijndeBoom(this); double afstandNaarGrens = bosWaarAapInIs.AfstandNaarRandVanBos(TijdelijkeBoom); if (afstandNaarGrens < pairAfstandEnBoom.Key) { GaUitBos(bosWaarAapInIs.ID); } else { int sprongId = VorigeBomen.Count; TijdelijkeBoom.VerwijderAapUitBoom(this); VorigeBomen.Add(sprongId, TijdelijkeBoom); TijdelijkeBoom = pairAfstandEnBoom.Value; TijdelijkeBoom.VoegAapToeAanBoom(this); Spring(bosWaarAapInIs); } }