private int CheckInBags(IPassenger passenger, IEnumerable <int> bagsToCheckIn) { var bags = passenger.Bags; var confiscatedBagCount = 0; foreach (var i in bagsToCheckIn) { var currentBag = bags[i]; bags.Remove(currentBag); if (ShouldConfiscate(currentBag)) { airport.AddConfiscatedBag(currentBag); confiscatedBagCount++; } else { this.airport.AddCheckedBag(currentBag); } } return(confiscatedBagCount); }
private int CheckInBags(IPassenger passenger, IEnumerable <int> bagsToCheckIn) { var bags = passenger.Bags; var confiscatedBagCount = 0; foreach (var bag in bagsToCheckIn.ToList()) //TODO: Added ToList, may need to be removed { var currentBag = bags[bag]; bags.RemoveAt(bag); if (ShouldConfiscate(currentBag)) { airport.AddConfiscatedBag(currentBag); confiscatedBagCount++; } else { this.airport.AddCheckedBag(currentBag); } } return(confiscatedBagCount); }