예제 #1
0
        private Wagon FindNewWagon()
        {
            if (Wagons == null)
            {
                Wagons = new List <Wagon>();
            }

            Wagon _newWagon = new Wagon();

            Wagons.Add(_newWagon);
            return(_newWagon);
        }
예제 #2
0
        //acutale algoritem
        public bool CheckIfAnimalFit(Wagon _selectedWagon, Animal _selectedAnimal)
        {
            if (_selectedAnimal.Type == 0)
            {
                var condition = _selectedWagon.AnimalsInWagon.Where(a => a.Size <= _selectedAnimal.Size);

                int _cap = _selectedWagon.WagonCapacity;

                bool fitAnimal = condition.ToList().Count == 0 &&
                                 (_cap += _selectedAnimal.Capacity) <= 10 && !_selectedWagon.containCarnivore;
                return(fitAnimal);
            }
            else
            {
                var condition = _selectedWagon.AnimalsInWagon.Where(a => (a.Size >= _selectedAnimal.Size) && (a.Type == 0));

                int _cap = _selectedWagon.WagonCapacity;

                bool fitAnimal = condition.ToList().Count == 0 &&
                                 (_cap += _selectedAnimal.Capacity) <= 10;
                return(fitAnimal);
            }
        }