using System.Collections.Generic;
private static readonly List<Animal> AnimalsToCheck = new List<Animal>
new Animal { Eater = Eater.Carnivore, Format = 1 },
new Animal { Eater = Eater.Herbivore, Format = 3 }
private static readonly List<Wagon> Wagons = new List<Wagon>
new Animal { Eater = Eater.Carnivore, Format = 5 },
new Animal { Eater = Eater.Herbivore, Format = 3 }
new Animal { Eater = Eater.Carnivore, Format = 1 }
public static void Checker(List<Animal> listAnimals)
foreach (var animal in listAnimals)
var wagonCount = Wagons.Count;
for (var i = 0; i < wagonCount; i++)
var animalCount = wagon.Animals.Count;
for (var j = 0; j < animalCount; j++)
var wagonAnimal = wagon.Animals[j];
if (wagon.StartCapacity <= wagon.MaxCapacity
&& animal.Format + wagon.StartCapacity <= wagon.MaxCapacity
&& wagonAnimal.Eater == Eater.Carnivore && animal.Eater == Eater.Herbivore
&& animal.Format >= wagonAnimal.Format)
wagon.Animals.Add(animal);
var newWagon = new Wagon();
newWagon.Animals.Add(animal);
public static void Main()
public Eater Eater { get; set; }
public int Format { get; set; }
public List<Animal> Animals = new List<Animal>();
public Wagon(int startCapacity, int maxCapacity, int format, List<Animal> animals)
this.StartCapacity = startCapacity;
this.MaxCapacity = maxCapacity;
public int Format { get; set; }
public int MaxCapacity { get; set; }
public int StartCapacity { get; set; }