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; } } } } } }
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); }
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); }
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); }
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; } } } } } }
public void CapacityCheck(Wagon wagon, Animal ianimal) { if (wagon.Capacity + ianimal.Weight <= 10) { } }
public void AddAnimal(Wagon wagon, Animal newAnimal) { wagon.Animalsinwagon.Add(newAnimal); wagon.Capacity += newAnimal.Weight; }
public void WagonMaker(Animal ianimal) { Wagon wagon = new Wagon(); AddAnimal(wagon, ianimal); }
public void WagonAvailable(Wagon wagon) { foreach (Wagon Wagon in Wagons) { } }
private void AddAnimalToNewWagon(Animal animal) { Wagon wagon = new Wagon(animal); AddWagon(wagon); }
private void AddWagon(Wagon wagon) { _wagons.Add(wagon); }