Beispiel #1
0
        /// <summary>
        /// Calculates and displays which items should go into discount, kept on shelf and ZWB based on the provided list
        /// </summary>
        /// <param name="productList">The list of the items to be categorized</param>
        /// <param name="productIcons">A dictionary contining the unlabeled icons of the items</param>
        /// <param name="isGroupingEnabled">If the list is grouped on creation. This CAN still be changed at runtime.
        public WasteBagForm(List <Product> productList, Dictionary <Product, Bitmap> productIcons, bool isGroupingEnabled)
        {
            InitializeComponent();

            var screen = Screen.FromControl(this);

            this.Width  = screen.WorkingArea.Width * 7 / 10;
            this.Height = screen.WorkingArea.Height * 9 / 10;

            this.productIcons      = productIcons;
            this.isGroupingEnabled = isGroupingEnabled;

            var products = new List <Product>();

            foreach (var prod in productList)
            {
                for (int i = 0; i < prod.Count; i++)
                {
                    products.Add(new Product(prod));
                }
            }

            WBConfig = new WasteBagConfiguration();
            logic    = new CategorizerLogic(products, WBConfig);

            InitializeLanes();
        }
Beispiel #2
0
        /// <summary>
        /// Generates the items that should be discounted and those that should be left on
        /// the shelfes, those that should get a discount and those that go into the Zero Waste Bags
        /// </summary>
        /// <param name="products">All products from the crate</param>
        /// <param name="config">Class containing all the configurations relevant to the set</param>
        public CategorizerLogic(List <Product> products, WasteBagConfiguration config)
        {
            this.products  = products;
            this.config    = config;
            expired        = new List <Product>();
            shelf          = new ShelfProducts();
            discounted     = new DiscountedProducts();
            ZWB_candidates = new ZeroWasteBag();

            ///Not only shorthand, but if the date changes during run, the results will be consistent
            DateTime today = DateTime.Today;

            ///ON the INFERENCE model: obtain object
            foreach (Product product in products)
            {
                /// In reality, this should not happen. Added for future-proofing
                if (product.ExpiryDate <= today) ///INFERENCE: obtain all attributes -> obtain feature
                {
                    expired.Add(product);        ///INFERENCE:  match Truth value => true; if false move to next clause
                }
                ///DISCOUNT: Expires tomorrow
                else if (product.ExpiryDate <= today.AddDays(1))
                {
                    discounted.Add(product);
                }
                ///SHELF: expires in 2 days, but has high facing or expires in more than 2 days
                else if (((product.ExpiryDate <= today.AddDays(2)) && (product.Facing >= 4)) ||
                         (product.ExpiryDate > today.AddDays(2)))
                {
                    shelf.Add(product);
                }
                ///ZWB: Expires in 2 days but has low facing
                else if ((product.ExpiryDate <= today.AddDays(2)) && (product.Facing <= 4))
                {
                    ZWB_candidates.Add(product);
                }
            }
            ///Sorts the ZWB products into the 5(or otherwise set by parameter) bags
            ZWB_final = generateWasteBags();
            foreach (var p in ZWB_candidates)
            {
                discounted.Add(p);
            }
            ZWB_candidates.Clear();
        }