コード例 #1
0
ファイル: Sort.cs プロジェクト: freaxy123/Containerschip
        public List <ContainerCooled> getContainersCooledSorted(List <IContainer> containers)
        {
            List <IContainer>      clonedList = new List <IContainer>(containers);
            List <ContainerCooled> sortedList = new List <ContainerCooled>();

            foreach (ContainerCooled container in containers.OfType <ContainerCooled>())
            {
                ContainerCooled maxContainerCooled = getMaxWeightContainerCooled(clonedList);
                sortedList.Add(maxContainerCooled);
                clonedList.Remove(maxContainerCooled);
            }
            return(sortedList);
        }
コード例 #2
0
ファイル: Sort.cs プロジェクト: freaxy123/Containerschip
        public ContainerCooled getMaxWeightContainerCooled(List <IContainer> containers)
        {
            int             maxWeight          = 0;
            ContainerCooled maxWeightContainer = null;

            foreach (ContainerCooled container in containers.OfType <ContainerCooled>())
            {
                if (container.weight > maxWeight)
                {
                    maxWeightContainer = container;
                    maxWeight          = container.weight;
                }
            }
            return(maxWeightContainer);
        }