コード例 #1
0
 public Container(int weight, Type type)
 {
     if (weight > MaxWeight || weight < MinWeight)
     {
         throw new ArgumentException("Weight must be between 4000 and 30000kg");
     }
     Weight = weight;
     Type   = type;
 }
コード例 #2
0
        private void bttn_AddContainers_Click(object sender, EventArgs e)
        {
            Type containerType   = getContainerType();
            int  containerWeight = Convert.ToInt32(nmrc_ContainerWeight.Value);

            for (int i = 0; i < nmrc_TotalContainersToAdd.Value; i++)
            {
                try
                {
                    unsortedContainers.Add(new Container(containerWeight, containerType));
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }

            updateContainerOverview();
        }