private void Btn_AddContainer_Click(object sender, EventArgs e)
        {
            Enum.TryParse(Cbbx_ContainerType.SelectedValue.ToString(), out ContainerType status);
            int weight = (int)Nud_ContainerWeight.Value;

            if (status == ContainerType.Regular)
            {
                Container newContainer = new Container(weight);
                _dock.AllContainers.Add(newContainer);
                Lbx_Containers.Items.Add(newContainer);
            }
            else if (status == ContainerType.Valuable)
            {
                ValuableContainer newContainer = new ValuableContainer(weight);
                _dock.AllContainers.Add(newContainer);
                Lbx_Containers.Items.Add(newContainer);
            }
            else if (status == ContainerType.Cooled)
            {
                CooledContainer newContainer = new CooledContainer(weight);
                _dock.AllContainers.Add(newContainer);
                Lbx_Containers.Items.Add(newContainer);
            }

            UpdateContainerStats();
        }
Example #2
0
        public bool CreateContainer(int index, int weight, TypeContainer type)
        {
            if (weight > 30 || weight < 4)
            {
                Program.PrintError("The Weight of The Container cant be more than 30 and less than 4");
                return(false);
            }

            if (type == TypeContainer.Default_Container)
            {
                var newContainer = new DefaultContainer(index, weight);
                containersList.Add(newContainer);
                return(true);
            }
            else if (type == TypeContainer.Cooled_Container)
            {
                var newContainer = new CooledContainer(index, weight);
                containersList.Add(newContainer);
                return(true);
            }
            else if (type == TypeContainer.Valuable_Container)
            {
                var newContainer = new ValuableContainer(index, weight);
                containersList.Add(newContainer);
                return(true);
            }
            else if (type == TypeContainer.RefrigeratedValuable_Container)
            {
                var newContainer = new ValuableCooledContainer(index, weight);
                containersList.Add(newContainer);
                return(true);
            }

            return(false);
        }
        public void CooledContainers_Placement()
        {
            //In this test I will test if the cooled containers are placed only on the first row. 4 containers, 2 rows.
            List <CooledContainer> listContainers = new List <CooledContainer>();
            CooledContainer        container1     = new CooledContainer(250);
            CooledContainer        container2     = new CooledContainer(250);
            CooledContainer        container3     = new CooledContainer(250);
            CooledContainer        container4     = new CooledContainer(250);

            ship.width  = 2;
            ship.length = 2;
            balanceAlgorithme.SetShip(ship);
            listContainers.Add(container1);
            listContainers.Add(container2);
            listContainers.Add(container3);
            listContainers.Add(container4);
            balanceAlgorithme.cList = listContainers;

            //Act
            balanceAlgorithme.FillShip();

            //Assert
            Assert.AreEqual(500, ship.rows[0].Stacks[0].weight);
            Assert.AreEqual(500, ship.rows[0].Stacks[1].weight);
            Assert.AreEqual(0, ship.rows[1].Stacks[0].weight);
            Assert.AreEqual(0, ship.rows[1].Stacks[1].weight);
        }
        public void IsContainerInCooledRow()
        {
            // Arange
            CooledContainer coolContainer1 = new CooledContainer(30);
            Stack           stack          = new Stack(0, 0, BalansPosition.Left); // Only Row[0]

            // Act
            stack.AddContainer(coolContainer1);
            bool isContainerInCooledRow = coolContainer1.ContainerType == ContainerType.Cooled &&
                                          stack.HasCooling;

            // Assert
            Assert.IsTrue(isContainerInCooledRow);
        }