Exemple #1
0
 //Xuất queue B
 static void XuatB(ListQueue B)
 {
     Console.WriteLine("Hang Cho :");
     for (Node p = B.Front; p != null; p = p.Next)
     {
         Console.Write("{0,-10}", p.Data);
     }
     Console.WriteLine();
 }
Exemple #2
0
        static void Main(string[] args)
        {
            //Khởi tạo danh sách số ghế trống A
            LinkedList <int> A = new LinkedList <int>();

            A = SetSoGheTrong(A);
            XuatLLA(A);

            //Khởi tạo danh sách thông tin khách mua vé C
            LinkedList <KhachHang> C = new LinkedList <KhachHang>();
            //XuatLLC(C);

            //Khởi tạo hàng đợi B chứa số thứ tự xếp hàng của khách
            ListQueue B = new ListQueue();

            //Menu
            int ichon = 0;

            do
            {
                Console.Clear();
                Menu();
                Console.Write("Ban hay chon chuc nang : ");
                int.TryParse(Console.ReadLine(), out ichon);
                switch (ichon)
                {
                case 1:
                    //Chức năng lấy số xếp hàng
                    LaySoXH(B);
                    break;

                case 2:

                    //Chức năng mua vé
                    MuaVe(A, B, C);
                    XuatLLC(C);
                    break;

                case 3:
                    //Chức năng hủy vé
                    HuyVe(A, C);
                    break;

                case 4:
                    //Hiển thị danh sách vé đã bán
                    XuatLLC(C);
                    break;

                default:
                    break;
                }
            } while (ichon > 0 && ichon <= 4);

            Console.ReadKey();
        }
Exemple #3
0
        //Chức năng lấy số xếp hàng
        static void LaySoXH(ListQueue B)
        {
            if (B.Front == null)
            {
                B.EnQueue(1);
            }
            else
            {
                //Thêm 1 Khách Hàng mua vé
                int tam = B.Rear.Data;

                B.EnQueue(tam + 1);
            }
            XuatB(B);
            Console.ReadKey();
        }
Exemple #4
0
        //Chức năng mua vé
        static void MuaVe(LinkedList <int> A, ListQueue B, LinkedList <KhachHang> C)
        {
            if (A.First == null)
            {
                Console.WriteLine("Rap da het cho!");
                Console.ReadKey();
            }
            else
            {
                if (B.Front == null)
                {
                    Console.WriteLine("Hang cho Rong!");
                    Console.ReadKey();
                }
                else
                {
                    XuatLLA(A);

                    Console.Write("Nhap ten KH : ");
                    string tenKH = Console.ReadLine();

                    int soghe = -1;
                    do
                    {
                        Console.Write("Nhap so ghe : ");
                        int.TryParse(Console.ReadLine(), out soghe);
                    } while (A.Find(soghe) == null);

                    //Xóa nút B
                    B.DeQueue();

                    //Thêm nút vào C
                    C.AddLast(new KhachHang(soghe, tenKH));
                    Console.WriteLine("Khach hang {0} dat cho thanh cong!", tenKH);
                }
            }
        }