下划线表示错误“setSpeedX
并非所有代码路径都返回值”。我可以知道如何解决吗?代码如下:
class Ball
{
public int speedX { get; private set; }
public int speedY { get; private set; }
public int positionX { get; private set; }
public int positionY { get; private set; }
public Ball(int speedX, int speedY, int positionX, int positionY)
{
this.speedX = speedX;
this.speedY = speedY;
this.positionX = positionX;
this.positionY = positionY;
}
public int setSpeedX(int newSpeedX)
{
speedX = newSpeedX;
}
public int setSpeedY(int newSpeedY)
{
speedY = newSpeedY;
}
public int setPositionX(int newPositionX)
{
positionX = newPositionX;
}
public int setPositionY(int newPositionY)
{
positionY = newPositionY;
}
}
谢谢你。