Я получаю эту ошибку, когда пытаюсь использовать подключенный к нему btn:
private void btnAccel_Click(object sender, EventArgs e)
{
pStatus.Text = plane.speed.ToString();
plane.speed = double.Parse(txtSpeed.Text);
plane.Accelerate();
pStatus.Text = plane.speed.ToString();
}
pStatus - это панель, которую я использую, и обновляю текущую скорость до и после увеличения скорости.plane
определено выше как:
Airplane plane = new Airplane();
Кажется, что ошибка возникает, когда она достигает plane.Accelerate();
public void Accelerate()
{
// increase the speed of the airplane
if (PlanePosition.speed < Position.MAX_SPEED)
{
PlanePosition.speed = PlanePosition.speed + 1; // or speed += 1;
}//end of if
numberCreated++; // increment the numberCreated each time an Airplane object is created
}//end of public Accelerate()
В этой первой строке if(PlanePosition.speed < Position.MAX_SPEED)
происходит продолжениечто VS говорит мне.
//private variables
private string name{get; set;}
private Position planePosition;
private static int numberCreated;
//default constructor
public Airplane()
{
}//end of public Airplane
public Position PlanePosition{get;set;}
class Position
{
//private variables
internal int x_coordinate;
internal int y_coordinate;
internal double speed;
internal int direction;
internal const int MAX_SPEED = 50;
//default constructor
public Position()
{
}//end of public Position
public string displayPosition()
{
return "okay";
}//end of public string displayPosition()
}//end of class Position