コード例 #1
0
        public static void LaunchMenu(ClientClass client)
        {
            bool stopflag = false;

            Console.WriteLine($"Welcome, {client.FirstName}!");
            while (true)
            {
                if (client.Status == 0)
                {
                    Console.WriteLine("\nChoose option:\n1 - exit\n2 - rent a car\n3 - return rented car");
                }
                else
                {
                    Console.WriteLine("\nChoose option:\n1 - exit\n2 - rent a car\n3 - return rented car\n4 - print all cars\n5 - print all rents\n6 - print transactions history");
                }
                ConsoleKeyInfo UserInput = Console.ReadKey();
                Console.Clear();
                Console.WriteLine();
                if (char.IsDigit(UserInput.KeyChar))
                {
                    switch (int.Parse(UserInput.KeyChar.ToString()))
                    {
                    case 1:
                    {
                        stopflag = true;
                        break;
                    }

                    case 2:
                    {
                        RentCar(client);
                        break;
                    }

                    case 3:
                    {
                        ReturnCar(client);
                        break;
                    }

                    case 4:
                    {
                        if (client.Status != 1)
                        {
                            goto default;
                        }
                        Console.WriteLine("All cars in autopark:\n");
                        AutoParkService.PrintAllCars();
                        EndCase();
                        break;
                    }

                    case 5:
                    {
                        if (client.Status != 1)
                        {
                            goto default;
                        }
                        Console.WriteLine("All current rents:\n");
                        RentService.PrintAllRents();
                        EndCase();
                        break;
                    }

                    case 6:
                    {
                        if (client.Status != 1)
                        {
                            goto default;
                        }
                        Console.WriteLine($"Current income: {TransactionService.TotalAmount}\n");
                        Console.WriteLine("Transactions history:\n");
                        //TransactionService.PrintTransactionsHistory();
                        EndCase();
                        break;
                    }

                    default:
                    {
                        Console.Clear();
                        Console.WriteLine("Wrong input!");
                        break;
                    }
                    }
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("Wrong input!");
                }
                if (stopflag)
                {
                    break;
                }
            }
            Console.Clear();
            Console.WriteLine("All rents:\n");
            RentService.PrintAllRents();
            Console.WriteLine("\n\nAll transactions:\n");
            //TransactionService.PrintAllTransactions();
            Console.ReadKey();
            return;
        }