To be specific, im focusing on test 8 right now. It says that after 23 “.Drive()” the battery is at 76% though its at 77% but in vs code all working fine.
Code:
using System;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
/*var car = new RemoteControlCar();
for (var i = 0; i < 23; i++)
{
car.Drive();
}
Console.WriteLine(car.BatteryDisplay());
*/
public class RemoteControlCar
{
private static int carsBought = 0;
private static int battery = 100;
private static int distance = 0;
public static string Buy()
{
carsBought += 1;
return $"Car {carsBought}";
}
public string DistanceDisplay()
{
//return "Driven " + distance + "meters";
return $"Driven {distance.ToString()} meters";
}
public string BatteryDisplay()
{ if (battery >= 1)
{
return $"Battery at {battery.ToString()}%";
}
else
{
return "Battery empty";
}
}
public void Drive()
{
if (battery >= 1)
{
distance += 20;
battery -= 1;
}
}
}
And don’t mind other problems, i’ll solve them afterwards.