예제 #1
0
        public void AddWagon(Animal animal)
        {
            Wagon wagon = new Wagon();

            wagons.Add(wagon);
            wagon.AddAnimal(animal);
            amountOfWagons++;
        }
예제 #2
0
        public void LoadTrain(List <Animal> animals)
        {
            int wagonIndex = 0;

            while (animals.Count != 0)
            {
                AddWagon(wagonIndex, animals[0]);
                Wagon wagon = Wagons[wagonIndex];
                animals.RemoveAt(0);

                for (int i = animals.Count - 1; i >= 0; i--)
                {
                    Animal animal = animals[i];
                    if (wagon.AddAnimal(animal))
                    {
                        animals.Remove(animal);
                    }
                }
                wagonIndex += 1;
            }
        }