Beispiel #1
0
        static void Main(string[] args)
        {
            OrderItem order1_item1 = new OrderItem("bag", 2, 200);
            OrderItem order1_item2 = new OrderItem("socks", 3, 10);
            OrderItem order1_item3 = new OrderItem("pants", 2, 100);
            OrderItem order1_item4 = new OrderItem("shoes", 1, 105);
            OrderItem order1_item5 = new OrderItem("hat", 3, 15);



            OrderItem order2_item1 = new OrderItem("bag", 1, 200);
            OrderItem order2_item2 = new OrderItem("socks", 5, 10);
            OrderItem order2_item3 = new OrderItem("pants", 5, 100);
            OrderItem order2_item4 = new OrderItem("shoes", 2, 105);
            OrderItem order2_item5 = new OrderItem("hat", 3, 15);

            OrderItem order3_item1 = new OrderItem("bag", 3, 200);
            OrderItem order3_item2 = new OrderItem("socks", 5, 10);
            OrderItem order3_item3 = new OrderItem("pants", 4, 100);

            OrderItem order4_item1 = new OrderItem("bag", 3, 200);
            OrderItem order4_item2 = new OrderItem("socks", 5, 10);
            OrderItem order4_item3 = new OrderItem("pants", 4, 100);


            Order order1 = new Order("X010101", "000001");
            Order order2 = new Order("X001100", "000001");
            Order order3 = new Order("X001101", "000002");
            Order order4 = new Order("X001103", "000004");

            order1.AddOrderItem(order1_item1);
            order1.AddOrderItem(order1_item1);
            order1.AddOrderItem(order1_item2);
            order1.AddOrderItem(order1_item3);
            order1.AddOrderItem(order1_item4);
            order1.AddOrderItem(order1_item5);

            order2.AddOrderItem(order2_item1);
            order2.AddOrderItem(order2_item2);
            order2.AddOrderItem(order2_item3);
            order2.AddOrderItem(order2_item4);
            order2.AddOrderItem(order2_item5);

            order3.AddOrderItem(order3_item1);
            order3.AddOrderItem(order3_item2);
            order3.AddOrderItem(order3_item3);

            order4.AddOrderItem(order4_item1);
            order4.AddOrderItem(order4_item2);
            order4.AddOrderItem(order4_item3);

            OrderService orderService = new OrderService();

            orderService.AddOrder(order1);
            orderService.AddOrder(order1);
            orderService.AddOrder(order2);
            Console.WriteLine();
            Console.WriteLine("订单添加后排序:");
            orderService.OrderSort();
            Console.WriteLine();
            Console.WriteLine("订单查询:");
            orderService.CheckOrderID("X010101");
            Console.WriteLine();
            Console.WriteLine("订单查询:");
            orderService.CheckOrderCardID("000001");

            Console.WriteLine();
            Console.WriteLine("订单修改后排序:");
            orderService.AlertOrder(order1, order3);
            orderService.OrderSort();
            Console.WriteLine();
            Console.WriteLine("订单修改:");
            orderService.AlertOrder(order4, order1);

            Console.WriteLine();
            Console.WriteLine("订单删除后排序:");
            orderService.DeleteOrder(order2);
            orderService.OrderSort();
            Console.WriteLine();
            Console.WriteLine("订单删除:");
            orderService.DeleteOrder(order4);


            orderService.Export("D:/order.xml");
            Console.WriteLine();
            orderService.DeleteOrder(order1);
            orderService.DeleteOrder(order2);
            Console.WriteLine();
            orderService.OrderSort();
            Console.WriteLine();
            orderService.Import("D:/order.xml");
            Console.WriteLine();
            orderService.OrderSort();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Goods goods1 = new Goods("football", 1);                                          //测试数据
            Goods goods2 = new Goods("basketball", 2);
            Goods goods3 = new Goods("volleyball", 3);
            Goods goods4 = new Goods("water", 4);
            Goods goods5 = new Goods("chocolate", 5);

            Client client1 = new Client("z");
            Client client2 = new Client("zz");
            Client client3 = new Client("zzz");

            OrderItem orderItem1 = new OrderItem(goods1, 1);
            OrderItem orderItem2 = new OrderItem(goods2, 2);
            OrderItem orderItem3 = new OrderItem(goods3, 3);
            OrderItem orderItem4 = new OrderItem(goods4, 4);
            OrderItem orderItem5 = new OrderItem(goods5, 5);

            OrderItem[] orderItems1 = { orderItem1, orderItem2 };
            OrderItem[] orderItems2 = { orderItem2, orderItem3 };
            OrderItem[] orderItems3 = { orderItem2, orderItem3, orderItem4 };
            OrderItem[] orderItems4 = { orderItem2, orderItem4 };

            Order order1 = new Order(1, client1, orderItems1);

            order1.calculate();
            Order order2 = new Order(2, client2, orderItems2);

            order2.calculate();
            Order order3 = new Order(3, client3, orderItems4);

            order3.calculate();

            OrderService orderService = new OrderService();

            orderService.add(order2);
            orderService.add(order1);
            orderService.add(order3);
            Console.Write("当前保存的订单编号序列: ");
            orderService.showID();
            orderService.modify(3, order3);
            Console.WriteLine();
            Console.Write("默认排序后的订单编号序列: ");
            orderService.sort();
            orderService.showID();
            Console.WriteLine();
            Console.WriteLine("删除订单编号为3的订单");
            orderService.sub(3);
            Console.Write("当前保存的订单编号序列: ");
            orderService.showID();
            Console.WriteLine("\n");
            Console.WriteLine("查询z的订单");
            List <Order> zorders = orderService.querybyClient("z");

            foreach (Order order in zorders)
            {
                Console.WriteLine(order);
            }
            Console.WriteLine("\n");
            Console.WriteLine("查询购买了basketball的订单");
            List <Order> forders = orderService.querybyGoods("basketball");

            foreach (Order order in forders)
            {
                Console.WriteLine(order);
            }
            orderService.Export();
            orderService.Import();
            Console.ReadKey();
        }