Exemple #1
0
        public static void LeftoverFill()
        {
            for (int i = 0; i < _herbivores.Count; i++)
            {
                if (_herbivores[i].AnimalSize != 0)
                {
                    _leftovers.Add(_herbivores[i]);
                }
            }

            if (_leftovers.Count > 0)
            {
                var clonedLeftovers = _leftovers.DeepClone();

                Wagon wagon = new Wagon(clonedLeftovers[0]);
                _wagons.Add(wagon);
                _leftovers[0].AnimalSize = 0;
                int check = wagon.CheckIfFilled();
                if (check < 10)
                {
                    for (int i = 1; i < _leftovers.Count; i++)
                    {
                        if (_leftovers[i].AnimalSize + check <= 10)
                        {
                            wagon.AddAnimal(clonedLeftovers[i]);
                            _leftovers[i].AnimalSize = 0;
                            check = check + clonedLeftovers[i].AnimalSize;
                        }
                    }
                }

                for (int i = 0; i < _leftovers.Count; i++)
                {
                    if (_leftovers[i].AnimalSize != 0)
                    {
                        Wagon wagon2 = new Wagon(clonedLeftovers[i]);
                        _wagons.Add(wagon2);
                        _leftovers[i].AnimalSize = 0;
                        int check2 = wagon2.CheckIfFilled();
                        for (int j = 0; j < _leftovers.Count; j++)
                        {
                            if (_leftovers[j].AnimalSize + check2 <= 10 && _leftovers[j].AnimalSize != 0)
                            {
                                wagon.AddAnimal(clonedLeftovers[i]);
                                _leftovers[j].AnimalSize = 0;
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        public bool BevatGrootsteFormaatDierInWagon(Wagon wagon)
        {
            bool bevatGrootsteFormatDier = false;

            foreach (Dier dierWagon in wagon.LijstDieren)
            {
                if (dierWagon.Grootte == circustrein.Grootte.Groot.ToString())
                {
                    bevatGrootsteFormatDier = true;
                    break;
                }
            }
            return(bevatGrootsteFormatDier);
        }
Exemple #3
0
        private static void PlaceHerbivoreInWagon(Animal animal)
        {
            foreach (var listWagon in wagons)
            {
                bool status = listWagon.CheckAnimalAndAddToWagon(animal);

                if (status == true)
                {
                    return;
                }
            }
            Wagon wagon = new Wagon();

            wagon.CheckAnimalAndAddToWagon(animal);
            wagons.Add(wagon);
        }
Exemple #4
0
        public static List <Wagon> AnimalsToWagons(List <Animal> animalList)
        {
            wagons.Clear();
            var animals = animalList.OrderBy(animal => animal.AnimalSize).ThenBy(animal => animal.AnimalType);

            foreach (var animal in animals)
            {
                if (animal.AnimalType == AnimalType.Carnivore)
                {
                    Wagon wagon = new Wagon();
                    wagon.CheckAnimalAndAddToWagon(animal);
                    wagons.Add(wagon);
                }
                else
                {
                    PlaceHerbivoreInWagon(animal);
                }
            }

            return(wagons);
        }
Exemple #5
0
        public static void CreateWagon()
        {
            Animal[] meatAnimalses    = _carnivores.ToArray();
            var      clonedHerbivores = _herbivores.DeepClone();

            for (int i = 0; i < meatAnimalses.Length; i++)
            {
                if (meatAnimalses[i].AnimalSize == 5)
                {
                    Wagon wagon = new Wagon(meatAnimalses[i]);
                    _wagons.Add(wagon);
                }
                else if (meatAnimalses[i].AnimalSize == 3)
                {
                    Wagon wagon = new Wagon(meatAnimalses[i]);
                    _wagons.Add(wagon);

                    for (int j = 0; j < _herbivores.Count; j++)
                    {
                        if (_herbivores[j].AnimalSize == 5)
                        {
                            wagon.AddAnimal(clonedHerbivores[j]);
                            _herbivores[j].AnimalSize = 0;
                            break;
                        }
                    }
                }
                else if (meatAnimalses[i].AnimalSize == 1)
                {
                    Wagon wagon = new Wagon(meatAnimalses[i]);
                    _wagons.Add(wagon);
                    int count = 0;

                    for (int j = 0; j < _herbivores.Count; j++)
                    {
                        if (_herbivores[j].AnimalSize == 3)
                        {
                            wagon.AddAnimal(clonedHerbivores[j]);
                            _herbivores[j].AnimalSize = 0;

                            count++;
                            if (count == 3)
                            {
                                break;
                            }
                        }
                    }
                    int check = wagon.CheckIfFilled();
                    if (check < 5)
                    {
                        for (int j = 0; j < _herbivores.Count; j++)
                        {
                            if (_herbivores[j].AnimalSize == 5)
                            {
                                wagon.AddAnimal(clonedHerbivores[j]);
                                _herbivores[j].AnimalSize = 0;
                                break;
                            }
                        }
                    }
                }
            }
        }
Exemple #6
0
 public void CapacityCheck(Wagon wagon, Animal ianimal)
 {
     if (wagon.Capacity + ianimal.Weight <= 10)
     {
     }
 }
Exemple #7
0
 public void AddAnimal(Wagon wagon, Animal newAnimal)
 {
     wagon.Animalsinwagon.Add(newAnimal);
     wagon.Capacity += newAnimal.Weight;
 }
Exemple #8
0
        public void WagonMaker(Animal ianimal)
        {
            Wagon wagon = new Wagon();

            AddAnimal(wagon, ianimal);
        }
Exemple #9
0
 public void WagonAvailable(Wagon wagon)
 {
     foreach (Wagon Wagon  in  Wagons)
     {
     }
 }
Exemple #10
0
        private void AddAnimalToNewWagon(Animal animal)
        {
            Wagon wagon = new Wagon(animal);

            AddWagon(wagon);
        }
Exemple #11
0
 private void AddWagon(Wagon wagon)
 {
     _wagons.Add(wagon);
 }