Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Item item1 = new Item("大英", 1);
            Item item2 = new Item("物理", 2);
            Item item3 = new Item("高数", 3);
            Item item4 = new Item("软基", 4);
            Item item5 = new Item("计组", 5);

            Client client1 = new Client("陈博宇");
            Client client2 = new Client("博宇陈");
            Client client3 = new Client("宇陈博");

            OrderDetails orderItem1 = new OrderDetails(item1, 1);
            OrderDetails orderItem2 = new OrderDetails(item2, 2);
            OrderDetails orderItem3 = new OrderDetails(item3, 3);
            OrderDetails orderItem4 = new OrderDetails(item4, 4);
            OrderDetails orderItem5 = new OrderDetails(item5, 5);

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

            Order order1 = new Order(10001, client1, orderItems1);
            order1.Calculate();
            Order order2 = new Order(10002, client2, orderItems2);
            order2.Calculate();
            Order order3 = new Order(10003, client3, orderItems3);
            order3.Calculate();
            Order order4 = new Order(10002, client3, orderItems4);
            order4.Calculate();

            OrderService orderService = new OrderService();
            orderService.AddOrder(order2);
            orderService.AddOrder(order1);
            orderService.AddOrder(order3);
            
            Console.Write("当前订单序列: ");
            orderService.ShowOrders();
            Console.WriteLine();
            
            Console.Write("按订单号排序后的订单序列: ");
            orderService.SortByNum();
            orderService.ShowOrders();
            Console.WriteLine();
            
            Console.WriteLine("删除订单编号为10000的订单");
            orderService.RemoveOrder(10000);

            Console.Write("修改订单序号为10002的订单: ");
            orderService.ModifyOrder(10002, order4);

            Console.Write("当前订单序列: ");
            orderService.ShowOrders();
            Console.WriteLine();

            Console.WriteLine("查询宇陈博的订单");
            List<Order> porders = orderService.OrderByClient("宇陈博");
            foreach (Order order in porders)
            {
                Console.Write(order);
            }
            Console.ReadKey();
        }
Ejemplo n.º 2
0
 public OrderDetails(Item items, int itemsNum)
 {
     Items = items;
     ItemsNum = itemsNum;
 }