我想知道是否有任何方法可以在方法之间进行数学加法?代码如下。
From Main:(我需要计算但我不能在方法之间进行计算)
Ball.setPositionY = Ball.setPositionY + Ball.setSpeedY;
从一个类:
public class Ball
{
public int speedX { get; set; }
public int speedY { get; set; }
public int positionX { get; set; }
public int positionY { get; set; }
public Ball(int speedX, int speedY, int positionX, int positionY)
{
this.speedX = speedX;
this.speedY = speedY;
this.positionX = positionX;
this.positionY = positionY;
}
public void setSpeedX(int newSpeedX)
{
speedX = newSpeedX;
}
public void setSpeedY(int newSpeedY)
{
speedY = newSpeedY;
}
public void setPositionX(int newPositionX)
{
positionX = newPositionX;
}
public void setPositionY(int newPositionY)
{
positionY = newPositionY;
}
}