private void CreateStacksOfType(Types.ContainerType containerType) { //Gets all the containers of a specific type List <Container> containersOfType = _toBeStackedContainers.FindAll(c => c.Type == containerType); foreach (var container in containersOfType) { bool containerIsAdded = false; //...and tries to place it in a stack... for (int i = 0; i < _containerStacks.Count && !containerIsAdded; i++) { if (_containerStacks[i].StackContainer(container)) { containerIsAdded = true; } //If it can't be placed onto any stack, create a new stack else if (i == _containerStacks.Count - 1) { ContainerStack newStack = new ContainerStack(container); _containerStacks.Add(newStack); containerIsAdded = true; } } } }
//Constructor public Container(int weight, Types.ContainerType type) { //Initializes fields Weight = weight; Type = type; }