我想知道方法之间是否有任何方法可以进行数学加法?代码如下.
从Main :(我需要计算,但我不能在方法之间进行计算)
Ball.setPositionY = Ball.setPositionY + Ball.setSpeedY;
Run Code Online (Sandbox Code Playgroud)
来自一个班级:
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 = …Run Code Online (Sandbox Code Playgroud) 我有很多INT变量,blueBallVelocityX1,blueBallVelocityX2,blueBallVelocityX3,blueBallVelocityX4,blueBallVelocityX5,blueBallVelocityX6,blueBallVelocityX7,blueBallVelocityX8,blueBallVelocityX9,blueBallVelocityX10,blueBallVelocityX11,blueBallVelocityX12,blueBallVelocityX13,blueBallVelocityX14,blueBallVelocityX15,blueBallVelocityX16,blueBallVelocityX17,blueBallVelocityX18,blueBallVelocityX19,blueBallVelocityX20和blueBallVelocityY1(1- 20).我需要指定值为5的所有变量.我该怎么办?