예제 #1
0
        public void addCarToParking()
        {
            Console.WriteLine("Select type of the car:");
            Console.WriteLine("1 - Passenger");
            Console.WriteLine("2 - Truck");
            Console.WriteLine("3 - Bus");
            Console.WriteLine("4 - Motorcycle");

            try
            {
                int carType = carType = Convert.ToInt32(Console.ReadLine());
                if (carType < 1 || carType > 4)
                {
                    throw new Exception();
                }

                Console.WriteLine("Please, enter the balance of the car");

                double carBalance = Convert.ToDouble(Console.ReadLine());
                if (carBalance <= 0)
                {
                    throw new Exception();
                }

                Car car = new Car((CarType)carType, carBalance, carIdentificator);

                carIdentificator++;

                parking.addCar(car);

                Console.WriteLine("The car with Id " + car.Id + " was successfully added to the parking");
            }

            catch (Exception)
            {
                Console.WriteLine("Please, enter the valid data abount car");
            }
        }