Пример #1
0
        public void GetSparePart_True()
        {
            SparePartService sparePart = new SparePartService();

            var result = sparePart.GetSparePart("Nitro");

            Assert.IsNotNull(result, "The item was found");
        }
Пример #2
0
        public void ImproveCar()
        {
            Console.WriteLine("Enter name:");
            string name = Console.ReadLine();

            var driver = driverService.GetDriver(name);

            if (driver != null)
            {
                var balanceOfTheRider = driverService.GetBalance(name);

                if (balanceOfTheRider != null)
                {
                    Console.WriteLine("Enter the name of the spare part for the car:");
                    var spatePart = Console.ReadLine();

                    var isSparePart = sparePartService.GetSparePart(spatePart);

                    if (isSparePart != null)
                    {
                        if (isSparePart.NumberOfImprovements < 5)
                        {
                            if (balanceOfTheRider.Amount >= isSparePart.Price)
                            {
                                Console.WriteLine("Enter the name of the machine you want to improve:");
                                var nameOfCar = Console.ReadLine();

                                var car = carService.GetCarFromGarage(name, nameOfCar);

                                if (car != null)
                                {
                                    Console.WriteLine($"The car has improved | There was a maximum speed of - {car.MaxSpeed}");
                                    car.MaxSpeed += isSparePart.PercentageOfImprovement;
                                    Console.WriteLine($"The car has improved | The maximum speed has become of - {car.MaxSpeed}");
                                    isSparePart.NumberOfImprovements++;
                                }
                            }
                            else
                            {
                                Console.WriteLine("You don't have enough money.");
                            }
                        }
                        else
                        {
                            Console.WriteLine("You have run out of attempts to improve the car.");
                        }
                    }
                    else
                    {
                        Console.WriteLine("There is no such spare part.");
                    }
                }
            }
            else
            {
                Console.WriteLine("There is no such participant.");
            }
        }