So basically I am trying to make it interpret if I input more than 200 horsepower, the speed should change increasingly by 15, which works, if I input "BMW" then the speed should go up with 10, which doesn't work and I cant figure out why, and if the horsepower is less than 200 and the brand isn't BMW, it should increase by 5, which also works.
public string brand;
public string model;
public int hp;
public int speed = 25;
public int GetSpeed()
{
return this.speed;
}
public void SetSpeed(int newspeed)
{
if (speed < 0 || speed > 260)
{
Console.WriteLine("Please input a valid speed");
}
else
{
this.speed = newspeed;
}
}
public string GetBrand()
{
return this.brand;
}
public void SetBrand(string newbrand)
{
this.brand = newbrand;
}
public string GetModel()
{
return this.model;
}
public void SetModel(string newmodel)
{
this.model = newmodel;
}
public int GetHp()
{
return this.hp;
}
public void SetHp(int newhp)
{
this.hp = newhp;
}
public int Accelerate(int step = 10, int new_speed = 5, int hpov = 15)
{
if (hp >= 200)
{
this.speed += hpov;
if (brand == "BMW")
{
this.speed += step;
}
}
else if (brand != "BMW")
{
this.speed += new_speed;
}
return this.speed;
}
}
}