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."); } }
public void SrartTheRace() { Console.WriteLine("Enter name:"); string name = Console.ReadLine(); var driver = ListData.ListDrivers.FirstOrDefault(x => x.Name == name); if (driver != null) { Console.WriteLine("Enter the name of the car:"); string nameOfCar = Console.ReadLine(); var car = carService.GetCarFromGarage(name, nameOfCar); if (car != null) { var balance = driverService.GetBalance(name); var carComputer = carService.GetCarForComputer(car); Console.WriteLine(new string('-', 35)); Console.WriteLine($"Participant's car - {car.Name}"); Console.WriteLine($"Computer machine - {carComputer.Name}"); Console.WriteLine(new string('-', 35)); var winner = gameService.StartDriving(car, carComputer); if (winner) { Console.WriteLine($"Winner - {driver.Name}."); balance.Amount += 300; driver.Prizes += 1; driver.NumberOfRaces++; } else { driver.NumberOfRaces++; Console.WriteLine("The winner of the computer."); } } else { Console.WriteLine("You don't have this car."); } } else { Console.WriteLine("The participant is not found."); } }
public void PrintBalance() { Console.WriteLine("Enter name:"); string name = Console.ReadLine(); var balance = driverService.GetBalance(name); if (balance != null) { Console.WriteLine($"The balance of the rider {balance.NameDriver} = {balance.Amount}$"); } else { Console.WriteLine("There is no such participant."); } }
public void BuyCar() { Console.WriteLine("Enter name:"); string name = Console.ReadLine(); // Поиск гонщика var driver = driverService.GetDriver(name); if (driver != null) { var balanceOfDriver = driverService.GetBalance(name); if (balanceOfDriver != null) { Console.WriteLine("Enter the name of the car you want to buy:"); string nameCar = Console.ReadLine(); var car = Car.ListCars.FirstOrDefault(x => x.Name == nameCar); // Find a car var garage = driverService.GetGarage(name); // Garage search if (car != null) { if (balanceOfDriver.Amount >= car.Price) { garage.Cars.Add(car); balanceOfDriver.Amount -= car.Price; } else { Console.WriteLine("You don't have enough funds."); } } else { Console.WriteLine("There is no such car."); } } } }