示例#1
0
        private void ProcessResults(List <Container> list, ShipPosition direction, int width)
        {
            foreach (Container container in list)
            {
                switch (direction)
                {
                case ShipPosition.FrontLeft:
                    lbFrontLeft.Items.Add("Container with weight " + container.Weight);
                    containers.Remove(container);
                    break;

                case ShipPosition.FrontRight:
                    lbFrontRight.Items.Add("Container with weight " + container.Weight);
                    containers.Remove(container);
                    break;

                case ShipPosition.BackLeft:
                    lbBackLeft.Items.Add("Container with weight " + container.Weight);
                    containers.Remove(container);
                    break;

                case ShipPosition.BackRight:
                    lbBackRight.Items.Add("Container with weight " + container.Weight);
                    containers.Remove(container);
                    break;

                case ShipPosition.Left:
                    lbLeft.Items.Add("Container with weight " + container.Weight);
                    containers.Remove(container);
                    break;

                case ShipPosition.Right:
                    lbRight.Items.Add("Container with weight " + container.Weight);
                    containers.Remove(container);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(direction), direction, null);
                }
            }
        }
示例#2
0
 public ShipContainer(string type, int weight) : base(type, weight)
 {
     Assigned = false;
     Position = new ShipPosition();
 }