//
 // Single Machine Sale
 //
 public void machineSale(Machine machine, Product product)
 {
     int transactionID = this.newTransactionID();
     this.database.Append(new Transactions(transactionID, DateTime.Now, "Checking", product.Name, product.RetailPrice));
     this.database.Append(new Transactions(transactionID, DateTime.Now, machine.MachineID, product.Name, product.WholeSalePrice));
     machine.removeProduct(product);
 }
 public void Append_SelectAll_Product_UnitTest()
 {
     Database database = new Database();
     Product product1 = new Product("This is Not a Product", .25f);
     Product product2 = new Product("This is Not a Product2", .25f);
     database.Append(product1);
     database.Append(product2);
     List<Product> productList = database.SelectAllProduct();
     Assert.AreSame(productList[0], product1);
     Assert.AreSame(productList[1], product2);
 }
        public void MachineCheckProductSingleQuantity()
        {
            Database database = new Database();
            Machine machine1 = new Machine("Hartford", "Downtown", "M100");

            Product product1 = new Product("coke", .75f);
            Product product2 = new Product("snickers", .75f);

            machine1.addProduct(product1);
            machine1.addProduct(product2);

            database.Append(machine1);

            List<Machine> MachineList = database.SelectAllMachine();

            Assert.AreEqual(1, MachineList[0].getSingleQuantity("coke"));
        }
        public void MachineCheckProductTypeNames()
        {
            Database database = new Database();
            Machine machine1 = new Machine("Hartford", "Downtown", "M100");

            Product product1 = new Product("coke", .75f);
            Product product2 = new Product("snickers", .75f);

            machine1.addProduct(product1);
            machine1.addProduct(product2);
            List<string> expected = new List<string> { "coke", "snickers" };

            database.Append(machine1);

            List<Machine> MachineList = database.SelectAllMachine();

            CollectionAssert.AreEqual(expected, MachineList[0].getProductNames());
        }
        public void MachineUpdateRetailPrice()
        {
            Database database = new Database();
            Machine machine1 = new Machine("Hartford", "Downtown", "M100");

            Product product1 = new Product("coke", .75f);
            Product product2 = new Product("snickers", .75f);

            machine1.addProduct(product1);
            machine1.addProduct(product2);
            machine1.updateRetailPrice("coke", 2.00f);
            float expected = 2.00f;

            database.Append(machine1);

            List<Machine> MachineList = database.SelectAllMachine();

            Assert.AreEqual(expected, product1.RetailPrice);
        }
Example #6
0
 //
 // Remove Database Entries
 //
 public void Remove(Product entry)
 {
     listProduct.Remove(entry);
 }
Example #7
0
 //
 // Append Database Entries
 //
 public void Append(Product entry)
 {
     listProduct.Add(entry);
 }
Example #8
0
        public void generateInitialProducts()
        {
            int transactionID = 1;
            for (int i = 0; i < 50; i++)
            {
                Product product1 = new Product("Snickers", .25f);
                Product product2 = new Product("Milky Way", .25f);
                Product product3 = new Product("Mounds", .25f);
                Product product4 = new Product("Almond Joy", .25f);
                Product product5 = new Product("Coke", .25f);
                Product product6 = new Product("Sprite", .25f);
                Product product7 = new Product("Dr. Pepper", .25f);
                Product product8 = new Product("Doritos", .25f);
                Product product9 = new Product("Fritos", .25f);
                Product product10 = new Product("Lays", .25f);
                listProduct.Add(product1);
                listProduct.Add(product2);
                listProduct.Add(product3);
                listProduct.Add(product4);
                listProduct.Add(product5);
                listProduct.Add(product6);
                listProduct.Add(product7);
                listProduct.Add(product8);
                listProduct.Add(product9);
                listProduct.Add(product10);

                Transactions transaction1 = new Transactions(++transactionID, DateTime.Now.AddMinutes(-2900), "Checking", "Snickers", -.25f);
                Transactions transaction2 = new Transactions(++transactionID, DateTime.Now.AddMinutes(-2900), "Checking", "Milky Way", -.25f);
                Transactions transaction3 = new Transactions(++transactionID, DateTime.Now.AddMinutes(-2900), "Checking", "Mounds", -.25f);
                Transactions transaction4 = new Transactions(++transactionID, DateTime.Now.AddMinutes(-2900), "Checking", "Almond Joy", -.25f);
                Transactions transaction5 = new Transactions(++transactionID, DateTime.Now.AddMinutes(-2900), "Checking", "Coke", -.25f);
                Transactions transaction6 = new Transactions(++transactionID, DateTime.Now.AddMinutes(-2900), "Checking", "Sprite", -.25f);
                Transactions transaction7 = new Transactions(++transactionID, DateTime.Now.AddMinutes(-2900), "Checking", "Dr. Pepper", -.25f);
                Transactions transaction8 = new Transactions(++transactionID, DateTime.Now.AddMinutes(-2900), "Checking", "Doritos", -.25f);
                Transactions transaction9 = new Transactions(++transactionID, DateTime.Now.AddMinutes(-2900), "Checking", "Fritos", -.25f);
                Transactions transaction10 = new Transactions(++transactionID, DateTime.Now.AddMinutes(-2900), "Checking", "Lays", -.25f);

                listTransactions.Add(transaction1);
                listTransactions.Add(transaction2);
                listTransactions.Add(transaction3);
                listTransactions.Add(transaction4);
                listTransactions.Add(transaction5);
                listTransactions.Add(transaction6);
                listTransactions.Add(transaction7);
                listTransactions.Add(transaction8);
                listTransactions.Add(transaction9);
                listTransactions.Add(transaction10);
            }
        }
 //Overload TransferOut method for single item
 public void TransferFromMachine(Machine machine, Product product)
 {
     List<Product> productList = new List<Product>();
     productList.Add(product);
     this.TransferFromMachine(machine, productList);
 }
Example #10
0
 // removes product from product list. If there is no product left, then type is removed from product Type.
 public void removeProduct(Product product)
 {
     int getProductQuantity = getSingleQuantity(product.Name);
     if (getProductQuantity == 1)
     {
         removeProductType(product.Name);
     }
     products.Remove(product);
     List<string> checkRestockItems = getItemsRestock();
     if (checkRestockItems.Count() > 0)
     {
         needRestock = true;
     }
     else
     {
         needRestock = false;
     }
 }
Example #11
0
        //End of Setter/Getter Section
        // adds product to products list and if necessary adds type to productTypes
        // assigns min stock level to be defaultMinStock for type if necessary.
        public bool addProduct(Product product)
        {
            if (products.Count() < maxCapacity)
            {
                List<string> productNames = getProductTypeNames();
                string productName = product.Name;
                if (productNames.Contains(productName))
                {
                    products.Add(product);
                    List<string> checkRestockItems = getItemsRestock();
                    if (checkRestockItems.Count() > 0)
                    {
                        needRestock = true;
                    }
                    else
                    {
                        needRestock = false;
                    }
                    return true;
                }
                else
                {
                    List<string> newProductType = new List<string>();
                    string productRestock = defaultMinStock.ToString();
                    newProductType.Add(productName);
                    newProductType.Add(productRestock);
                    productTypes.Add(newProductType);

                    products.Add(product);
                    List<string> checkRestockItems = getItemsRestock();
                    if (checkRestockItems.Count() > 0)
                    {
                        needRestock = true;
                    }
                    else
                    {
                        needRestock = false;
                    }
                    return true;
                }
            }
            else
            {
                return false;
            }
        }