Ejemplo n.º 1
0
        //遊戲函式
        // static void game()
        // {

        // }

        //主程式
        static void Main(string[] args)
        {
            //儲存所有會員資料
            Member[] m = new Member[30];
            for (int a = 0; a < 30; a++)
            {
                m[a] = new Member(" ", " ", " ", " ");
            }
            Res1 r1 = new Res1();
            Res2 r2 = new Res2();
            Res3 r3 = new Res3();

            Console.WriteLine("Welcome to Mealink!!");
            Console.WriteLine();
            Console.WriteLine("What you want to do ? (1. Register/Login 2. Reservation 3. Game 0. Logout) : ");
            int choice = int.Parse(Console.ReadLine());

            while (true)
            {
                if (choice > 0 && choice <= 3)
                {
                    switch (choice)
                    {
                    case 1:
                        login(m);
                        Console.WriteLine("What you want to do ? (1. Register/Login 2. Reservation 3. Game 0. Logout) : ");
                        choice = int.Parse(Console.ReadLine());
                        break;

                    case 2:
                        reserve(m, r1, r2, r3);
                        Console.WriteLine("What you want to do ? (1. Register/Login 2. Reservation 3. Game 0. Logout) : ");
                        choice = int.Parse(Console.ReadLine());
                        break;

                    case 3:
                        //game(m);
                        Console.WriteLine("What you want to do ? (1. Register/Login 2. Reservation 3. Game 0. Logout) : ");
                        choice = int.Parse(Console.ReadLine());
                        break;
                    }
                }
                else if (choice == 0)
                {
                    Console.WriteLine("Thanks for your visiting !! Have a good day!");
                    Console.WriteLine("Press any key to exit...");
                    Console.ReadKey();
                    break;
                }
                else
                {
                    Console.WriteLine("Please enter a number in [0-3]!!");
                    Console.WriteLine("What you want to do ? (1. Register/Login 2. Reservation 3. Game 0. Logout) : ");
                    choice = int.Parse(Console.ReadLine());
                }
            }
        }
Ejemplo n.º 2
0
        //訂位函式
        static void reserve(Member[] m, Res1 r1, Res2 r2, Res3 r3)
        {
            int Uid = 0;

            Console.Write("Do you have a membership? (Y/N): ");
            string UcheMem = Console.ReadLine();

            while (true)
            {
                //擁有會員身分
                if (UcheMem.ToLower() == "yes" || UcheMem.ToLower() == "y")
                {
                    //提供會員名稱
                    Console.WriteLine("Please tell us your registered email?");
                    string Uacc = Console.ReadLine();
                    while (true)
                    {
                        if (checkMail(Uacc) == true)
                        {
                            checkRegis(m, Uacc, Uid);
                            while (Uid != 0)
                            {
                                switch (m[Uid].FavCuisine)
                                {
                                case "Chinese":
                                    Console.WriteLine("Hello, {0}! Your favorite cuisine is {1}, we recommend restaurant 1 for you!!", m[Uid].Name, m[Uid].FavCuisine);
                                    break;

                                case "West":
                                    Console.WriteLine("Hello, {0}! Your favorite cuisine is {1}, we recommend restaurant 2 for you!!", m[Uid].Name, m[Uid].FavCuisine);
                                    break;

                                case "Multi-cultural":
                                    Console.WriteLine("Hello, {0}! Your favorite cuisine is {1}, we recommend restaurant 3 for you!!", m[Uid].Name, m[Uid].FavCuisine);
                                    break;
                                }
                                //預約流程
                                while (true)
                                {
                                    Console.WriteLine("Please choose a restaurant you like from the following list(1. Chinese Food 2. West Food 3. Multi-cultural Food) :");
                                    int resN = int.Parse(Console.ReadLine());
                                    //預約的餐廳與預約的座位形式
                                    string resRest, sType;
                                    while (true)
                                    {
                                        if (resN >= 1 && resN <= 3)
                                        {
                                            switch (resN)
                                            {
                                            case 1:
                                                resRest = "Chinese Food";
                                                Console.WriteLine("How many people will visit?");
                                                int pNum = int.Parse(Console.ReadLine());
                                                //3人(含)安排窗邊位子
                                                if (pNum > 0 && pNum <= 3 && r1.Wins != 0)
                                                {
                                                    r1.Wins--;
                                                    sType = "Windowsides";
                                                    Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                }
                                                //4~6人(含)安排走道位子
                                                else if (pNum > 3 && pNum <= 6 && r1.Aisle != 0)
                                                {
                                                    r1.Aisle--;
                                                    sType = "Aislesides";
                                                    Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                }
                                                //6~10人(含)安排包廂
                                                else if (pNum > 6 && pNum <= 10 && r1.Booth != 0)
                                                {
                                                    r1.Booth--;
                                                    sType = "Booth";
                                                    Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                }
                                                //超過10人,不可預約
                                                else if (pNum > 10)
                                                {
                                                    Console.WriteLine("Sorry, our restaurant can contain only ten people each table at most.");
                                                }
                                                //所要預訂的形式已滿
                                                else
                                                {
                                                    Console.WriteLine("Sorry, our restaurant is full!");
                                                }
                                                break;

                                            case 2:
                                                resRest = "West Food";
                                                Console.WriteLine("How many people will visit?");
                                                pNum = int.Parse(Console.ReadLine());
                                                if (pNum > 0 && pNum <= 3 && r2.Wins != 0)
                                                {
                                                    r2.Wins--;
                                                    sType = "Windowsides";
                                                    Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                }
                                                else if (pNum > 3 && pNum <= 6 && r2.Aisle != 0)
                                                {
                                                    r2.Aisle--;
                                                    sType = "Aislesides";
                                                    Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                }
                                                else if (pNum > 6 && pNum <= 10 && r2.Booth != 0)
                                                {
                                                    r2.Booth--;
                                                    sType = "Booth";
                                                    Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                }
                                                else if (pNum > 10)
                                                {
                                                    Console.WriteLine("Sorry, our restaurant can contain only ten people each table at most.");
                                                }
                                                else
                                                {
                                                    Console.WriteLine("Sorry, our restaurant is full!");
                                                }
                                                break;

                                            case 3:
                                                resRest = "Multi-cultural Food";
                                                Console.WriteLine("How many people will visit?");
                                                pNum = int.Parse(Console.ReadLine());
                                                if (pNum > 0 && pNum <= 3 && r3.Wins != 0)
                                                {
                                                    r3.Wins--;
                                                    sType = "Windowsides";
                                                    Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                }
                                                else if (pNum > 3 && pNum <= 6 && r3.Aisle != 0)
                                                {
                                                    r3.Aisle--;
                                                    sType = "Aislesides";
                                                    Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                }
                                                else if (pNum > 6 && pNum <= 10 && r3.Booth != 0)
                                                {
                                                    r3.Booth--;
                                                    sType = "Booth";
                                                    Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                }
                                                else if (pNum > 10)
                                                {
                                                    Console.WriteLine("Sorry, our restaurant can contain only ten people each table at most.");
                                                }
                                                else
                                                {
                                                    Console.WriteLine("Sorry, our restaurant is full!");
                                                }
                                                break;
                                            }
                                        }
                                        else
                                        {
                                            Console.WriteLine("Please re-choose a restaurant you like from the following list(1. Chinese Food 2. West Food 3. Multi-cultural Food) :");
                                            resN = int.Parse(Console.ReadLine());
                                            continue;
                                        }
                                        break;
                                    }
                                    break;
                                }
                                break;
                            }

                            while (Uid == 0)
                            {
                                Console.Write("Oops...You have never been our membership! Do you want to register and obtain more discount,now? (y/n): ");
                                string Udes = Console.ReadLine();
                                if (Udes.ToLower() == "yes" || Udes.ToLower() == "y")
                                {
                                    login(m);
                                    break;
                                }
                                else if (Udes.ToLower() == "no" || Udes.ToLower() == "n")
                                {
                                    while (true)
                                    {
                                        Console.WriteLine("Please choose a restaurant you like from the following list(1. Chinese Food 2. West Food 3. Multi-cultural Food) :");
                                        int resN = int.Parse(Console.ReadLine());
                                        //預約的餐廳與預約的座位形式
                                        string resRest, sType;
                                        while (true)
                                        {
                                            if (resN >= 1 && resN <= 3)
                                            {
                                                switch (resN)
                                                {
                                                case 1:
                                                    resRest = "Chinese Food";
                                                    Console.WriteLine("How many people will visit?");
                                                    int pNum = int.Parse(Console.ReadLine());
                                                    //3人(含)安排窗邊位子
                                                    if (pNum > 0 && pNum <= 3 && r1.Wins != 0)
                                                    {
                                                        r1.Wins--;
                                                        sType = "Windowsides";
                                                        Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                    }
                                                    //4~6人(含)安排走道位子
                                                    else if (pNum > 3 && pNum <= 6 && r1.Aisle != 0)
                                                    {
                                                        r1.Aisle--;
                                                        sType = "Aislesides";
                                                        Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                    }
                                                    //6~10人(含)安排包廂
                                                    else if (pNum > 6 && pNum <= 10 && r1.Booth != 0)
                                                    {
                                                        r1.Booth--;
                                                        sType = "Booth";
                                                        Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                    }
                                                    //超過10人,不可預約
                                                    else if (pNum > 10)
                                                    {
                                                        Console.WriteLine("Sorry, our restaurant can contain only ten people each table at most.");
                                                    }
                                                    //所要預訂的形式已滿
                                                    else
                                                    {
                                                        Console.WriteLine("Sorry, our restaurant is full!");
                                                    }
                                                    break;

                                                case 2:
                                                    resRest = "West Food";
                                                    Console.WriteLine("How many people will visit?");
                                                    pNum = int.Parse(Console.ReadLine());
                                                    if (pNum > 0 && pNum <= 3 && r2.Wins != 0)
                                                    {
                                                        r2.Wins--;
                                                        sType = "Windowsides";
                                                        Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                    }
                                                    else if (pNum > 3 && pNum <= 6 && r2.Aisle != 0)
                                                    {
                                                        r2.Aisle--;
                                                        sType = "Aislesides";
                                                        Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                    }
                                                    else if (pNum > 6 && pNum <= 10 && r2.Booth != 0)
                                                    {
                                                        r2.Booth--;
                                                        sType = "Booth";
                                                        Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                    }
                                                    else if (pNum > 10)
                                                    {
                                                        Console.WriteLine("Sorry, our restaurant can contain only ten people each table at most.");
                                                    }
                                                    else
                                                    {
                                                        Console.WriteLine("Sorry, our restaurant is full!");
                                                    }
                                                    break;

                                                case 3:
                                                    resRest = "Multi-cultural Food";
                                                    Console.WriteLine("How many people will visit?");
                                                    pNum = int.Parse(Console.ReadLine());
                                                    if (pNum > 0 && pNum <= 3 && r3.Wins != 0)
                                                    {
                                                        r3.Wins--;
                                                        sType = "Windowsides";
                                                        Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                    }
                                                    else if (pNum > 3 && pNum <= 6 && r3.Aisle != 0)
                                                    {
                                                        r3.Aisle--;
                                                        sType = "Aislesides";
                                                        Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                    }
                                                    else if (pNum > 6 && pNum <= 10 && r3.Booth != 0)
                                                    {
                                                        r3.Booth--;
                                                        sType = "Booth";
                                                        Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                                    }
                                                    else if (pNum > 10)
                                                    {
                                                        Console.WriteLine("Sorry, our restaurant can contain only ten people each table at most.");
                                                    }
                                                    else
                                                    {
                                                        Console.WriteLine("Sorry, our restaurant is full!");
                                                    }
                                                    break;
                                                }
                                            }
                                            else
                                            {
                                                Console.WriteLine("Please re-choose a restaurant you like from the following list(1. Chinese Food 2. West Food 3. Multi-cultural Food) :");
                                                resN = int.Parse(Console.ReadLine());
                                                continue;
                                            }
                                            break;
                                        }
                                        break;
                                    }
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Error!Enter y/n");
                                    Console.Write("Do you want to register and obtain more discount,now? (y/n): ");
                                    Udes = Console.ReadLine();
                                    continue;
                                }
                            }
                            break;
                        }
                        else
                        {
                            Console.WriteLine("Please re-enter your registered email!");
                            Uacc = Console.ReadLine();
                            continue;
                        }
                    }
                }
                //沒有會員
                else if (UcheMem.ToLower() == "no" || UcheMem.ToLower() == "n")
                {
                    //請求註冊
                    Console.WriteLine("Do you want to register and obtain more discount,now? (y/n): ");
                    string Udes = Console.ReadLine();
                    while (true)
                    {
                        if (Udes.ToLower() == "yes" || Udes.ToLower() == "y")
                        {
                            login(m);
                            break;
                        }
                        else if (Udes.ToLower() == "no" || Udes.ToLower() == "n")
                        {
                            while (true)
                            {
                                Console.WriteLine("Please choose a restaurant you like from the following list(1. Chinese Food 2. West Food 3. Multi-cultural Food) :");
                                int resN = int.Parse(Console.ReadLine());
                                //預約的餐廳與預約的座位形式
                                string resRest, sType;
                                while (true)
                                {
                                    if (resN >= 1 && resN <= 3)
                                    {
                                        switch (resN)
                                        {
                                        case 1:
                                            resRest = "Chinese Food";
                                            Console.WriteLine("How many people will visit?");
                                            int pNum = int.Parse(Console.ReadLine());
                                            //3人(含)安排窗邊位子
                                            if (pNum > 0 && pNum <= 3 && r1.Wins != 0)
                                            {
                                                r1.Wins--;
                                                sType = "Windowsides";
                                                Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                            }
                                            //4~6人(含)安排走道位子
                                            else if (pNum > 3 && pNum <= 6 && r1.Aisle != 0)
                                            {
                                                r1.Aisle--;
                                                sType = "Aislesides";
                                                Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                            }
                                            //6~10人(含)安排包廂
                                            else if (pNum > 6 && pNum <= 10 && r1.Booth != 0)
                                            {
                                                r1.Booth--;
                                                sType = "Booth";
                                                Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                            }
                                            //超過10人,不可預約
                                            else if (pNum > 10)
                                            {
                                                Console.WriteLine("Sorry, our restaurant can contain only ten people each table at most.");
                                            }
                                            //所要預訂的形式已滿
                                            else
                                            {
                                                Console.WriteLine("Sorry, our restaurant is full!");
                                            }
                                            break;

                                        case 2:
                                            resRest = "West Food";
                                            Console.WriteLine("How many people will visit?");
                                            pNum = int.Parse(Console.ReadLine());
                                            if (pNum > 0 && pNum <= 3 && r2.Wins != 0)
                                            {
                                                r2.Wins--;
                                                sType = "Windowsides";
                                                Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                            }
                                            else if (pNum > 3 && pNum <= 6 && r2.Aisle != 0)
                                            {
                                                r2.Aisle--;
                                                sType = "Aislesides";
                                                Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                            }
                                            else if (pNum > 6 && pNum <= 10 && r2.Booth != 0)
                                            {
                                                r2.Booth--;
                                                sType = "Booth";
                                                Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                            }
                                            else if (pNum > 10)
                                            {
                                                Console.WriteLine("Sorry, our restaurant can contain only ten people each table at most.");
                                            }
                                            else
                                            {
                                                Console.WriteLine("Sorry, our restaurant is full!");
                                            }
                                            break;

                                        case 3:
                                            resRest = "Multi-cultural Food";
                                            Console.WriteLine("How many people will visit?");
                                            pNum = int.Parse(Console.ReadLine());
                                            if (pNum > 0 && pNum <= 3 && r3.Wins != 0)
                                            {
                                                r3.Wins--;
                                                sType = "Windowsides";
                                                Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                            }
                                            else if (pNum > 3 && pNum <= 6 && r3.Aisle != 0)
                                            {
                                                r3.Aisle--;
                                                sType = "Aislesides";
                                                Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                            }
                                            else if (pNum > 6 && pNum <= 10 && r3.Booth != 0)
                                            {
                                                r3.Booth--;
                                                sType = "Booth";
                                                Console.WriteLine("Reservation succeed! You reserve a {0} in {1} .", sType, resRest);
                                            }
                                            else if (pNum > 10)
                                            {
                                                Console.WriteLine("Sorry, our restaurant can contain only ten people each table at most.");
                                            }
                                            else
                                            {
                                                Console.WriteLine("Sorry, our restaurant is full!");
                                            }
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("Please re-choose a restaurant you like from the following list(1. Chinese Food 2. West Food 3. Multi-cultural Food) :");
                                        resN = int.Parse(Console.ReadLine());
                                        continue;
                                    }
                                }
                            }
                        }
                        else
                        {
                            //輸入格式錯誤
                            Console.Write("Error!Enter y/n");
                            Console.Write("Do you remember your password? (y/n) :");
                            Udes = Console.ReadLine();
                            continue;
                        }
                    }
                }
                else
                {
                    //輸入格式錯誤
                    Console.Write("Error!Enter y/n");
                    Console.Write("Do you remember your password? (y/n) :");
                    UcheMem = Console.ReadLine();
                    continue;
                }
                break;
            }
        }