예제 #1
0
        public Trein()
        {
            Treinwagons = new List <Treinwagon>();
            Treinwagon treinwagon = new Treinwagon(0);

            Treinwagons.Add(treinwagon);
            AlleDieren = new List <Dier>();
        }
예제 #2
0
        private void AddDier(Dier dier)
        {
            bool animalIsAdded = false;

            for (int i = 0; i < Treinwagons.Count && !animalIsAdded; i++)
            {
                if (Treinwagons[i].AddDier(dier))
                {
                    animalIsAdded = true;
                }
                else if (i == Treinwagons.Count - 1)
                {
                    Treinwagon newtreinwagon = new Treinwagon(i + 1);
                    Treinwagons.Add(newtreinwagon);
                    Treinwagons[i + 1].AddDier(dier);
                    animalIsAdded = true;
                }
            }
        }