示例#1
0
        private void RemoveCarMenuItem()
        {
            var busyPlaces = Parking.GetNumberOfBusyPlaces();

            if (busyPlaces == 0)
            {
                Console.WriteLine("There are no cars in the parking.");
            }
            else
            {
                Console.WriteLine($"To remove the car, please, enter the number of this car from 1 to {busyPlaces}:");
                var numberOfCar = GetAndValidateInputInt(1, busyPlaces);
                if (_parking.HasFine(numberOfCar))
                {
                    Console.WriteLine("The car has a fine. Would you like to top up balance (press any number key except 0) or no (press 0)?");
                    var i = GetAndValidateInputInt(0, 9);
                    if (i == 0)
                    {
                        Console.WriteLine("The car was not removed.");
                        return;
                    }
                }
                var balance = _parking.RemoveCar(numberOfCar).Result;
                Console.WriteLine($"Balance was {balance}. The car removed.");
            }
        }
示例#2
0
        private void TopUpCarBalanceMenuItem()
        {
            var busyPlaces = Parking.GetNumberOfBusyPlaces();

            if (busyPlaces == 0)
            {
                Console.WriteLine("There are no cars in the parking.");
            }
            else
            {
                Console.WriteLine(
                    $"To top up car balance, please, enter the number of this car from 1 to {busyPlaces}:");
                var numberOfCar = GetAndValidateInputInt(1, busyPlaces);
                Console.WriteLine("Enter the amount of money:");
                var money = GetAndValidateInputDecimal();
                Console.WriteLine($"The balance is topped up. The new balance: {_parking.TopUp(numberOfCar, money)}");
            }
        }
示例#3
0
        public bool Action()
        {
            var flag  = true;
            var value = GetAndValidateInputInt(0, 8);

            Console.Clear();
            switch (value)
            {
            case 1:
                Console.WriteLine($"Total revenue: {_parking.GetTotalRevenue()}");
                break;

            case 2:
                Console.WriteLine($"Revenue for the last minute:{Parking.AmountForTheLastMinute()}");
                break;

            case 3:
                Console.WriteLine($"Free spaces: {_parking.GetNumberOfFreePlaces()}.\nBusy spaces: {Parking.GetNumberOfBusyPlaces()}.");
                break;

            case 4:
                AddCarMenuItem();
                break;

            case 5:
                RemoveCarMenuItem();
                break;

            case 6:
                TopUpCarBalanceMenuItem();
                break;

            case 7:
                DisplayTransactionsForTheLastMinuteMenuItem();
                break;

            case 8:
                DisplayTransactionsFileMenuItem();
                break;

            default:
                flag = false;
                break;
            }

            if (flag)
            {
                EndOfParagraph();
            }
            return(flag);
        }