Ejemplo n.º 1
0
 public void UpdateStockAndVolume(ContainableItemsCollection collection)
 {
     for (int index = 0; index < collection.Count(); index++)
     {
         this.actualStock.Add(new ActualStock(collection.Get(index).Product));
         this.volume.Add(new Volume(collection.Get(index).Product, collection.Get(index).Product.Quantity));
     }
 }
Ejemplo n.º 2
0
 static void AddingProducts(ContainableItemsCollection produse)
 {
     produse.Add(new ContainableItem(new Product("Covrigi", "Toortitzi", 5, 6), new Position(0, 0, 1)));
     produse.Add(new ContainableItem(new Product("Covrigi", "Croco", 3, 3), new Position(0, 1, 2)));
     produse.Add(new ContainableItem(new Product("Covrigi", "Toortitzi", 5, 4), new Position(0, 0, 1)));
     produse.Remove(new ContainableItem(new Product("Covrigi", "Croco", 3, 3), new Position(0, 1, 2)));
     produse.Add(new ContainableItem(new Product("Covrigi", "Cornelius", 2, 5), new Position(0, 1, 2)));
     produse.Add(new ContainableItem(new Product("Covrigi", "Croco", 3, 1), new Position(0, 3, 1)));
     WrintingProductsInVolumes(produse);
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            ContainableItemsCollection produse = new ContainableItemsCollection();

            produse.LocationOverlap += LocationOverlap;
            AddingProducts(produse);
            Dispenser       dispenser       = new Dispenser(produse);
            PaymentTerminal paymentTerminal = new PaymentTerminal(dispenser);

            VendingMachineConsole(produse, paymentTerminal);
        }
Ejemplo n.º 4
0
        static void WrintingProductsInVolumes(ContainableItemsCollection produse)
        {
            Node temp = produse.GetFirst();

            for (int i = 0; i < produse.Count(); i++)
            {
                int quantity = temp.ContainableItem.Product.GetSize();
                Data.Instance.AddToVolumes(temp.ContainableItem.Product, quantity);
                temp = temp.To;
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            int             paymentType = 0, id = 0, moreProducts = 1;
            PaymentTerminal payConsole = new PaymentTerminal();
            ContainableItem lays       = new ContainableItem(new Product(new ProductCategory("Snacks"), "Lays", 50, 10, 3), new Position(1, 1, 2, 2));
            ContainableItem M_m        = new ContainableItem(new Product(new ProductCategory("Sweets"), "M&M", 30, 20, 1), new Position(2, 1, 1, 1));
            ContainableItem milk       = new ContainableItem(new Product(new ProductCategory("Milk Products"), "Milk", 20, 40, 2), new Position(3, 1, 2, 3));

            ContainableItemsCollection.AddItem(lays);
            ContainableItemsCollection.AddItem(M_m);
            ContainableItemsCollection.AddItem(milk);

            ContainableItemsCollection.ShowList();
            while (moreProducts != 0)
            {
                try {
                    Console.WriteLine("Product id:");
                    id = Int32.Parse(Console.ReadLine());
                    Console.WriteLine("How do you want to pay? 1-Coins, 2-Banknote, 3-CreditCard, 0-Back");
                    paymentType = Int32.Parse(Console.ReadLine());
                } catch (Exception e) { Console.WriteLine(e); }

                switch (paymentType)
                {
                case 1:
                    Payment payCoin = new Coin();
                    payConsole.Pay(id, payCoin);
                    break;

                case 2:
                    Payment payBanknote = new Banknote();
                    payConsole.Pay(id, payBanknote);
                    break;

                case 3:
                    Payment payCreditCard = new CreditCard();
                    payConsole.Pay(id, payCreditCard);
                    break;

                default:
                    break;
                }
                Console.WriteLine(Dispenser.Message);
                try {
                    Console.WriteLine("Do you want to buy another product? 1-Yes 0-No");
                    moreProducts = Int32.Parse(Console.ReadLine());
                } catch (Exception e) { Console.WriteLine(e); }
            }

            DataAcquisition.GetInstance().GenerateReports();
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            List <Position>            positions  = new List <Position>();
            List <ProductCategory>     categories = new List <ProductCategory>();
            ContainableItemsCollection collection = new ContainableItemsCollection();

            VendingMachineSetup(positions, categories, collection);
            Dispenser       dispenser       = new Dispenser(collection);
            PaymentTerminal paymentTerminal = new PaymentTerminal(dispenser);

            paymentTerminal.ProductDispensed += ProductDispensed;
            MainMenu(paymentTerminal);
            dispenser.Report();
        }
Ejemplo n.º 7
0
        static void SaleOperation(ContainableItemsCollection produse, PaymentTerminal paymentTerminal)
        {
            int idProduct = -1;
            int option    = -1;

            while (option != 0 && idProduct != 0)
            {
                Node temp = produse.GetFirst();
                for (int i = 0; i < produse.Count(); i++)
                {
                    Console.WriteLine(temp.ContainableItem.ToString());
                    temp = temp.To;
                }
                Console.WriteLine("ID Product:");
                int.TryParse(Console.ReadLine(), out idProduct);
                Console.WriteLine("Payment Option: (1-Coins;2-Banknote;3-Card)");
                int.TryParse(Console.ReadLine(), out option);
                paymentTerminal.Pay(idProduct, option);
            }
        }
Ejemplo n.º 8
0
        private static void VendingMachineConsole(ContainableItemsCollection produse, PaymentTerminal paymentTerminal)
        {
            Boolean repeat = true;

            while (repeat)
            {
                try
                {
                    SaleOperation(produse, paymentTerminal);
                }
                catch (MyException myException)
                {
                    Console.WriteLine($"{myException.Problem}\nDo you want to try again?(anything/n)");
                    if (Console.ReadLine() == "n")
                    {
                        repeat = false;
                        Console.WriteLine("Have a nice day");
                    }
                }
            }
            Data.Instance.WritingCsv();
        }
Ejemplo n.º 9
0
 public Dispenser(ContainableItemsCollection collection)
 {
     containableItemsCollection = collection;
 }
Ejemplo n.º 10
0
        public static void VendingMachineSetup(List <Position> positions, List <ProductCategory> categories, ContainableItemsCollection collection)
        {
            positions.Add(new Position(1, 1, 1, 1));
            positions.Add(new Position(1, 2, 2, 2));
            positions.Add(new Position(1, 3, 1, 3));

            categories.Add(new ProductCategory("Snacks"));
            categories.Add(new ProductCategory("Sodas"));
            categories.Add(new ProductCategory("Sweets"));

            collection.Add(new ContainableItem(positions[0], new Product(positions[0], "Lays", 5, 2.5, categories[0])));
            collection.Add(new ContainableItem(positions[1], new Product(positions[1], "Cola", 1, 3, categories[1])));
            collection.Add(new ContainableItem(positions[2], new Product(positions[2], "Snickers", 0, 2.2, categories[2])));
        }
Ejemplo n.º 11
0
 public Dispenser(ContainableItemsCollection containableItemsCollection)
 {
     this.containableItemsCollection = containableItemsCollection;
     this.repository = Repository.Instance;
     this.repository.UpdateStockAndVolume(this.containableItemsCollection);
 }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            ProductCategory productCategory1 = new ProductCategory()
            {
                Name = "Ciocolata"
            };

            ProductCategory productCategory2 = new ProductCategory()
            {
                Name = "Suc"
            };

            Position position1 = new Position()
            {
                Row    = 1,
                Column = 2,
                Size   = 3,
                Id     = 1
            };

            Position position2 = new Position()
            {
                Row    = 2,
                Column = 1,
                Size   = 4,
                Id     = 2
            };

            Product product1 = new Product()
            {
                Category = productCategory1,
                Price    = 4.5,
                Quantity = 3,
                Name     = "Milka"
            };

            Product product2 = new Product()
            {
                Category = productCategory2,
                Price    = 6.3,
                Quantity = 2,
                Name     = "Sprite"
            };

            Product product3 = new Product()
            {
                Category = productCategory1,
                Price    = 3.1,
                Quantity = 1,
                Name     = "Poiana"
            };

            ContainableItem containableItem1 = new ContainableItem()
            {
                Position = position2,
                Product  = product1
            };

            ContainableItem containableItem2 = new ContainableItem()
            {
                Position = position1,
                Product  = product2
            };

            ContainableItem containableItem3 = new ContainableItem()
            {
                Position = position1,
                Product  = product3
            };

            ContainableItemsCollection containableItemsCollection = new ContainableItemsCollection();
            Dispenser dispenser = new Dispenser(containableItemsCollection);

            PaymentTerminal paymentTerminal = new PaymentTerminal(dispenser);
            Payment         payment         = new BanknotePayment();

            containableItemsCollection.AddProduct(containableItem1);
            containableItemsCollection.AddProduct(containableItem2);
            containableItemsCollection.AddProduct(containableItem3);

            //  containableItemsCollection.RemoveAt(2);

            for (int i = 0; i < containableItemsCollection.Count(); i++)
            {
                Console.WriteLine(containableItemsCollection.GetItem(i));
            }

            Console.WriteLine("After dispense:");

            paymentTerminal.Pay(0, payment, 50);

            //Product dispenseProduct = dispenser.Dispense(0);
            // Console.WriteLine(dispenseProduct);
        }