예제 #1
0
        //Main Program
        static void Main(string[] args)
        {
            //Creating Instance of Items and corresponding price per pack
            Item Item1 = new Item("Yougurt", "YT2");

            Item1.AddPricePerPack(4, 4.95M);
            Item1.AddPricePerPack(10, 9.95M);

            Item Item2 = new Item("Sliced Ham", "SH3");

            Item2.AddPricePerPack(3, 2.99M);
            Item2.AddPricePerPack(5, 4.49M);

            Item Item3 = new Item("Toilet Rolls", "TR");

            Item3.AddPricePerPack(3, 2.95M);
            Item3.AddPricePerPack(5, 4.45M);

            Item Item4 = new Item("Beer", "BR6");

            Item4.AddPricePerPack(6, 12.99M);
            Item4.AddPricePerPack(12, 24.00M);
            Item4.AddPricePerPack(24, 46.00M);

            Item Item5 = new Item("Paper Towels", "PT3");

            Item5.AddPricePerPack(3, 2.99M);
            Item5.AddPricePerPack(6, 5.00M);

            Item3.AddPricePerPack(5, 7.99M);
            Item3.AddPricePerPack(10, 9.00M);

            //Creating instance of a warehouse stock List to add items to it
            StockList warehouse1 = new StockList("Warehouse 1");

            warehouse1.AddItemToStockList(Item1);
            warehouse1.AddItemToStockList(Item2);
            warehouse1.AddItemToStockList(Item3);
            warehouse1.AddItemToStockList(Item4);
            warehouse1.AddItemToStockList(Item5);

            //Printing warehouse 1 stock file
            Console.WriteLine("\nWarehouse 1 stocks {0}", warehouse1.PrintStockFile());

            //Creating instance of a purchase order with order id 0001 specifying which warehouse it will be ordered from
            Order order1 = new Order("0001", warehouse1);

            //------------INPUT------------------
            order1.AddItemToOrder(15, "YT2");
            order1.AddItemToOrder(33, "SH3");
            order1.AddItemToOrder(40, "TR");
            order1.AddItemToOrder(4, "YT2");
            order1.AddItemToOrder(113, "BR6");

            Console.WriteLine("\n--INPUT--");
            Console.WriteLine("{0}", order1.PrintOrderSummary());

            //-------------OUTPUT------------------
            Console.WriteLine("--OUTPUT--");
            foreach (OrderLineItem o in order1.Items)
            {
                Console.WriteLine(o.CalcTotalPrice());
            }
        }