Beispiel #1
0
        public ProductWarehouseWithHistory(string productName, int capacity, int initialBalance) : base(productName, capacity)
        {
            this.productName      = productName;
            this.capacity         = capacity;
            this.initialBalance   = initialBalance;
            this.warehouseHistory = new ChangeHistory();


            AddToWarehouse(initialBalance);
        }
        public static void Main(string[] args)
        {
            /*ProductWarehouse juice = new ProductWarehouse("Juice", 1000);
             * juice.AddToWarehouse(1000);
             * juice.TakeFromWarehouse(11);
             * Console.WriteLine(juice.productName); // Juice
             * Console.WriteLine(juice);*/
            Warehouse wh = new Warehouse(100);

            Console.WriteLine(wh);
            wh.AddToWarehouse(10);
            Console.WriteLine(wh);
            wh.AddToWarehouse(100);
            Console.WriteLine(wh);
            wh.AddToWarehouse(-10);
            Console.WriteLine(wh);
            wh.TakeFromWarehouse(20);
            Console.WriteLine(wh);
            wh.TakeFromWarehouse(-20);
            Console.WriteLine(wh);

            Console.WriteLine();

            ProductWarehouse juice = new ProductWarehouse("Juice", 1000);

            juice.AddToWarehouse(1000);
            juice.TakeFromWarehouse(11);
            Console.WriteLine(juice.productName); // Juice
            Console.WriteLine(juice);

            Console.WriteLine();

            ChangeHistory cs = new ChangeHistory();

            cs.Add(100);
            cs.Add(10);
            cs.Add(200);
            cs.Add(50);
            Console.WriteLine(cs);

            Console.WriteLine();

            ProductWarehouseWithHistory milk = new ProductWarehouseWithHistory("Milk", 1000, 100);

            Console.WriteLine(milk);
            milk.TakeFromWarehouse(10);
            Console.WriteLine(milk.History());
            Console.WriteLine(milk);
            milk.AddToWarehouse(100);
            Console.WriteLine(milk.History());
            Console.WriteLine(milk);
            milk.TakeFromWarehouse(-10000);
            Console.WriteLine(milk.History());
            Console.WriteLine(milk);
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            //1..Part Warehouse
            Warehouse WH = new Warehouse(100);

            Console.WriteLine(WH);
            WH.AddToWarehouse(10);
            Console.WriteLine(WH);
            WH.AddToWarehouse(100);
            Console.WriteLine(WH);
            WH.AddToWarehouse(-10);
            Console.WriteLine(WH);
            WH.TakeFromWarehouse(20);
            Console.WriteLine(WH);
            WH.TakeFromWarehouse(-20);
            Console.WriteLine(WH);

            Console.WriteLine();

            //2..Part ProductWarehouse
            ProductWarehouse juice = new ProductWarehouse("Juice", 1000);

            juice.AddToWarehouse(1000);
            juice.TakeFromWarehouse(11);
            Console.WriteLine(juice.productName); // Juice
            Console.WriteLine(juice);

            Console.WriteLine();

            //3..Part ChangeHistory
            ChangeHistory CH = new ChangeHistory();

            CH.Add(100);
            CH.Add(10);
            CH.Add(200);
            CH.Add(50);
            Console.WriteLine(CH);

            Console.WriteLine();

            //4..Part ProductWarehouseWithHistory
            ProductWarehouseWithHistory milk = new ProductWarehouseWithHistory("Milk", 1000, 100);

            Console.WriteLine(milk);
            milk.TakeFromWarehouse(10);
            Console.WriteLine(milk.History());
            Console.WriteLine(milk);
            milk.AddToWarehouse(100);
            Console.WriteLine(milk.History());
            Console.WriteLine(milk);
            milk.TakeFromWarehouse(-10000);
            Console.WriteLine(milk.History());
            Console.WriteLine(milk);
        }